Ejemplo n.º 1
0
 public bool Update(AspNetUsers model)
 {
     AspNetUsers profile = GetById(model.Id);
     if (model.FIO != null)
         profile.FIO = model.FIO;
     if (model.Org != 0)
         profile.Org = model.Org;
     if (model.UserName != null)
         profile.UserName = model.UserName;
     if (model.Email != null)
         profile.Email = model.Email;
     if (model.PhoneNumber != null)
         profile.PhoneNumber = model.PhoneNumber;
     if (model.NotificationEmail != null)
         profile.NotificationEmail = model.NotificationEmail;
     if (model.NotificationPhone != null)
         profile.NotificationPhone = model.NotificationPhone;
     if (model.CallTimeStart != null)
         profile.CallTimeStart = model.CallTimeStart;
     if (model.CallTimeEnd != null)
         profile.CallTimeEnd = model.CallTimeEnd;
     try
     {
         _context.SaveChanges();
         return true;
     }
     catch { return false; };
 }
Ejemplo n.º 2
0
 public ActionResult SetSettings(SettingsViewModel model)
 {
     if (ModelState.IsValid)
     {
         AspNetUsers profile = new AspNetUsers
         {
             Id = model.UserId,
             Email = model.Email,
             PhoneNumber = model.Phone,
             NotificationEmail = model.NotificationEmail,
             NotificationPhone = model.NotificationPhone,
             CallTimeStart = TimeSpan.Parse(model.CallTimeStart),
             CallTimeEnd = TimeSpan.Parse(model.CallTimeEnd)
         };
         if (UserRepository.Update(profile))
             return Json(new { result = "OK" });
         else
         {
             ModelState.AddModelError("", "Не удалось сохранить данные");
             return PartialView("Settings", model);
         }
     }
     else
     {
         return PartialView("Settings", model);
     }
 }
Ejemplo n.º 3
0
 public SettingsViewModel(AspNetUsers model)
 {
     UserId = model.Id;
     FIO = model.FIO;
     Email = model.Email;
     NotificationEmail = model.NotificationEmail;
     NotificationPhone = model.NotificationPhone;
     CallTimeStart = model.CallTimeStart.ToString().Substring(0, 5);
     CallTimeEnd = model.CallTimeEnd.ToString().Substring(0, 5);
     Phone = model.PhoneNumber;
     Org = model.Org1.Name;
 }