Browse Source

god mode done for good

master
Milad Karbasizadeh 11 years ago
parent
commit
cce747549a
7 changed files with 62 additions and 42 deletions
  1. +21
    -17
      Sevomin.WebFrontend.Controllers/AccountController.cs
  2. +25
    -2
      Sevomin.WebFrontend.Controllers/AuthorizedController.cs
  3. +6
    -4
      Sevomin.WebFrontend.Controllers/HomeController.cs
  4. +1
    -0
      Sevomin.WebFrontend.Controllers/Sevomin.WebFrontend.Controllers.csproj
  5. +8
    -0
      Sevomin.WebFrontend/App_Start/RouteConfig.cs
  6. +1
    -0
      Sevomin.WebFrontend/Sevomin.WebFrontend.csproj
  7. +0
    -19
      Sevomin.WebFrontend/Views/Job/MiniApplication.cshtml

+ 21
- 17
Sevomin.WebFrontend.Controllers/AccountController.cs View File

@ -245,7 +245,7 @@ namespace Sevomin.WebFrontend.Controllers
}
[Authorize]
[Authorize(Roles = "Avalin,Dovomin")]
public async Task<ActionResult> MyProfile(bool? success)
{
if (success.HasValue)
@ -266,7 +266,7 @@ namespace Sevomin.WebFrontend.Controllers
}
}
[Authorize]
[Authorize(Roles = "Dovomin")]
[HttpPost]
public async Task<ActionResult> ProfileDovomin(string JalaliBirthDate, string FirstName,
string LastName, string ContactPersonEMail, bool IsFullTime,
@ -314,7 +314,7 @@ namespace Sevomin.WebFrontend.Controllers
}
}
[Authorize]
[Authorize(Roles = "Avalin")]
[HttpPost]
public async Task<ActionResult> ProfileAvalin(string CompanyName, string NationalId, string RegisterId,
string Address, string CompanyPhoneNumber, string EMail)
@ -350,23 +350,27 @@ namespace Sevomin.WebFrontend.Controllers
if ((user as Dovomin) == null)
return HttpNotFound();
if (User.IsInRole("Dovomin"))
if (!User.IsInRole("God"))
{
if (userId != user.Id)
if (User.IsInRole("Dovomin"))
{
return HttpNotFound();
if (userId != user.Id)
{
return HttpNotFound();
}
else { }
}
else if (User.IsInRole("Avalin"))
{
Avalin avalin = (await UserManager.FindByNameAsync(User.Identity.Name)) as Avalin;
bool showIt = avalin.Jobs.Any(j =>
{
bool ret = j.Applications.Any(c => c.DovominId == userId);
return ret;
});
if (!showIt)
return HttpNotFound();
}
else { }
}
else if (User.IsInRole("Avalin"))
{
Avalin avalin = (await UserManager.FindByNameAsync(User.Identity.Name)) as Avalin;
bool showIt = avalin.Jobs.Any(j => {
bool ret = j.Applications.Any(c => c.DovominId == userId);
return ret;
});
if (!showIt)
return HttpNotFound();
}
return View(new DovominViewModel(user as Dovomin));


+ 25
- 2
Sevomin.WebFrontend.Controllers/AuthorizedController.cs View File

@ -4,6 +4,7 @@ using Sevomin.Models.Helpers;
using System.IO;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Linq;
namespace Sevomin.WebFrontend.Controllers
{
@ -27,10 +28,32 @@ namespace Sevomin.WebFrontend.Controllers
if (string.IsNullOrWhiteSpace(userid))
userid = (await UserManager.FindByNameAsync(User.Identity.Name)).Id;
Dovomin user = await UserManager.FindByIdAsync(userid) as Dovomin;
if (user == null)
return HttpNotFound();
//ToDo: فکر کنم هر کسی که لاگ این کرده باشه میتونه رزومه هر کسی را دانلود کنه
if (!User.IsInRole("God"))
{
if (User.IsInRole("Dovomin"))
{
if (userid != user.Id)
{
return HttpNotFound();
}
else { }
}
else if (User.IsInRole("Avalin"))
{
Avalin avalin = (await UserManager.FindByNameAsync(User.Identity.Name)) as Avalin;
bool showIt = avalin.Jobs.Any(j =>
{
bool ret = j.Applications.Any(c => c.DovominId == userid);
return ret;
});
if (!showIt)
return HttpNotFound();
}
}
string path = Path.Combine(Server.MapPath("~/App_Data/resumes/"), english ? user.EnglishResume : user.PersianResume);
string fileDownloadName = string.Format("{0} {1} Resume{2}", user.DisplayName, english ? "English" : "Persian", Path.GetExtension(path));
return File(path, "application/octet-stream", fileDownloadName);


+ 6
- 4
Sevomin.WebFrontend.Controllers/HomeController.cs View File

@ -27,10 +27,12 @@ namespace Sevomin.WebFrontend.Controllers
else
{
User user = await UserManager.FindByNameAsync(User.Identity.Name);
if (user is Avalin)
return View("AvalinIndex");
else
return View("DovominIndex");
if (user is Avalin)
return View("AvalinIndex");
else if (user is Dovomin)
return View("DovominIndex");
else
return RedirectToAction("Index", "God");
}
}


+ 1
- 0
Sevomin.WebFrontend.Controllers/Sevomin.WebFrontend.Controllers.csproj View File

@ -94,6 +94,7 @@
<Compile Include="AccountController.cs" />
<Compile Include="AuthorizedController.cs" />
<Compile Include="BaseController.cs" />
<Compile Include="GodController.cs" />
<Compile Include="HomeController.cs" />
<Compile Include="JobController.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />


+ 8
- 0
Sevomin.WebFrontend/App_Start/RouteConfig.cs View File

@ -113,6 +113,14 @@ namespace Sevomin.WebFrontend
);
#endregion
#region God Mode
routes.MapRoute(
name: "TurnOnGodMode",
url: "god-mode/{action}",
defaults: new { controller = "God", action = "Index" }
);
#endregion
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",


+ 1
- 0
Sevomin.WebFrontend/Sevomin.WebFrontend.csproj View File

@ -331,6 +331,7 @@
<Content Include="Views\Account\ResetPassword.cshtml" />
<Content Include="Views\Account\ChangePassword.cshtml" />
<Content Include="Views\Shared\SocialMetaTags.cshtml" />
<Content Include="Views\God\Index.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>


+ 0
- 19
Sevomin.WebFrontend/Views/Job/MiniApplication.cshtml View File

@ -1,19 +0,0 @@
@model Sevomin.Models.JobApplicationViewModel
<div class="panel panel-default rtl">
<div class="panel-body">
<em>از طرف <a href="@Url.Action("Dovomin", "Account", new { userId = Model.DovominId })">@Model.DovominDisplayName</a></em>
<h4>@Model.JobSummary</h4>
@if (!string.IsNullOrWhiteSpace(Model.CoverLetter))
{
<h5>پیغام متخصص:</h5>
<blockquote>@Model.CoverLetter</blockquote>
}
@if (Model.MinimumRequirement){
<p>این متخصص تمامی مهارت های الزامی برای این فرصت شغلی را دارد. همچنین میزان مطابقت ایشان با این فرصت شغلی، @Model.Affinity درصد است.</p>
}
else {
<p>این متخصص برخی مهارت های الزامی برای این فرصت شغلی را ندارد. همچنین میزان مطابقت ایشان با این فرصت شغلی، @Model.Affinity درصد است.</p>
}
</div>
</div>

Loading…
Cancel
Save