Example #1
0
        public async Task<ActionResult> EditProfile(int id, AccountViewModel viewmodel)
        {
            var sites = await SiteRepository.GetAllAsync();
            viewmodel.Site = sites;

            var user = await UserRepository.SingleAsync(id);
            user.Firstname = viewmodel.FirstName;
            user.Lastname = viewmodel.LastName;
            user.SiteId = viewmodel.SiteId;
            user.Phone = viewmodel.Phone;

            if (ModelState.IsValid)
            {
                var result = await UserRepository.UpdateAsync(user);
                if (result == Model.SaveResult.SUCCESS)
                    ViewData["Result"] = "SUCESS";
                else
                    ViewData["Result"] = "FAILURE";
            }
            return View(viewmodel);
        }
Example #2
0
 public async Task<ActionResult> EditProfile(int id)
 {
     var acc = new AccountViewModel();
     var sites = await SiteRepository.GetAllAsync();
     var mySelf = await UserRepository.SingleAsync(id);
     if (mySelf != null)
     {
         acc.Id = mySelf.Id;
         acc.Email = mySelf.Email;
         acc.FirstName = mySelf.Firstname;
         acc.LastName = mySelf.Lastname;
         acc.Site = sites;
         acc.SiteId = mySelf.SiteId;
         acc.RoleName = mySelf.Role.Name;
         acc.RoleId = mySelf.RoleId;
         acc.RegisterDate = mySelf.RegistedDate;
         acc.Phone = mySelf.Phone;
     }
     return View(acc);
 }