public ActionResult UserInformation(AdministrationUserModel model) { ViewBag.IsEditMode = true; model.LevelsOfAccess = _userService.GetUserLevelsOfAccess(); ViewBag.IsCallCenter = _storeService.IsCallCenter(); // Check if user want to change his id if (model.UserId != _adminService.GetUserIdForEditing()) { // check if new userId is not unique if (_userService.IsUserIdExist(model.UserId)) { ModelState.AddModelError("UserId", "That ID already exists. "); return(View(model)); } } //// Check date if (ModelState.IsValid && _storeService.IsCallCenter()) { try { var date = String.Format("{0:00}/{1:00}/{2:0000}", model.Day, model.Month, model.Year); DateTime.ParseExact(date, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); } catch (Exception e) { ModelState.AddModelError("Day", "Wrong date."); ModelState.AddModelError("Month", " "); ModelState.AddModelError("Year", " "); } } // If model is valid, then try update user info if (ModelState.IsValid) { try { if (_storeService.IsCallCenter()) { _adminService.InsertOrUpdateCallCenterUser(model, _adminService.GetUserIdForEditing()); } else { _adminService.InsertOrUpdateUser(model, _adminService.GetUserIdForEditing()); } ViewBag.resultMsg = "<div class=\"success\">Saved Successfully</div>"; ViewBag.IsEditMode = false; _adminService.SetUserIdForEditing(model.UserId); } catch (Exception ex) { ViewBag.resultMsg = "<div class=\"error\">Save was not completed</div>"; } } return(View(model)); }