public static CreateEditProfileModel Build(string mineOrProfileId) { var mineId = int.Parse(mineOrProfileId); var mp = MineProfile.TryFind(mineId); if (mp != null) { mineId = mp.MineId; } var mine = App.Web.Business.Data.Mine.Find(mineId); var model = new CreateEditProfileModel { Id = mp != null ? mp.Id : 0, Mine = mine.DisplayName, MineId = mine.Id, MineIcon = mine.Icon, MineIconText = mine.IconName, MineDescription = mine.Description, MineTaxRate = Format.AsPercent(mine.TaxRate, 100), CustomAccount = mp != null ? mp.CustomAccount : string.Empty, CustomPassword = mp != null ? mp.CustomPassword : string.Empty }; return(model); }
public ActionResult Profile(string id, CreateEditProfileModel model) { try { var account = Account.FindBy(WebSecurity.CurrentUserId); var mineId = model.MineId; //int.Parse(collection["Id"]); var customAccount = model.CustomAccount; // collection["CustomAccount"]; var customPassword = model.CustomPassword; //collection["CustomPassword"]; MineProfile mp = null; if (model.Id > 0) { mp = MineProfile.TryFind(model.Id); } if (mp == null) { mp = new MineProfile(); mp.AccountId = account.Id; mp.MineId = mineId; } mp.CustomAccount = customAccount; mp.CustomPassword = customPassword; mp.Save(); return(RedirectToAction("Index", "Work")); } catch (Exception e) { ModelState.AddModelError("", e.Message); return(View(model)); } }