Browse Source

Account Controller + profile

confirmation-email
J 11 years ago
parent
commit
939b8343b7
1 changed files with 43 additions and 1 deletions
  1. +43
    -1
      Sevomin.WebFrontend.Controllers/AccountController.cs

+ 43
- 1
Sevomin.WebFrontend.Controllers/AccountController.cs View File

@ -7,6 +7,7 @@ using System;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Sevomin.Models.Repositories;
namespace Sevomin.WebFrontend.Controllers
{
@ -140,7 +141,7 @@ namespace Sevomin.WebFrontend.Controllers
}
[Authorize]
private async Task<ActionResult> Profile()
public async Task<ActionResult> MyProfile()
{
User u = await UserManager.FindByNameAsync(User.Identity.Name);
if (u is Avalin)
@ -155,5 +156,46 @@ namespace Sevomin.WebFrontend.Controllers
}
}
[Authorize]
[HttpPost]
public async Task<ActionResult> ProfileDovomin(string JalaliBirthDate, string FirstName,
string LastName, string ContactPersonEMail, bool IsFullTime,
bool IsPartTime, string Description, bool ShowCompanyLogo, FormCollection form)
{
User u = await UserManager.FindByNameAsync(User.Identity.Name);
if (u == null || !(u is Dovomin))
throw new InvalidOperationException("نوع کاربر صحیح نیست");
try
{
Dovomin dovomin = (Dovomin)u;
dovomin.BirthDate = DateAssist.ToMiladi(JalaliBirthDate);
dovomin.Description = Description;
dovomin.FirstName = FirstName;
dovomin.LastName = LastName;
dovomin.IsFulltime = IsFullTime;
dovomin.IsPartTime = IsPartTime;
ParameterRepository.Current.AddParametersToDovomin(dovomin);
foreach (var jp in dovomin.DovominParameters)
{
string value = form[string.Format("value-{0}", jp.Parameter.Id)];
byte moscow = 0;
byte.TryParse(form[string.Format("moscow-{0}", jp.Parameter.Id)], out moscow);
jp.SetValue(value);
jp.Moscow = moscow;
}
SevominDbContext.Current.SaveChanges();
}
catch (Exception)
{
throw;
}
DovominViewModel dvm = new DovominViewModel(u as Dovomin);
return View("ProfileDovomin", dvm);
}
}
}

Loading…
Cancel
Save