public async Task <IActionResult> EditLevel(string customerReminderId, string cid, CustomerReminderModel.ReminderLevelModel model, bool continueEditing) { var customerReminder = await _customerReminderService.GetCustomerReminderById(customerReminderId); if (customerReminder == null) { return(RedirectToAction("List")); } var level = customerReminder.Levels.FirstOrDefault(x => x.Id == cid); if (level == null) { return(RedirectToAction("List")); } if (level.Level != model.Level) { if (customerReminder.Levels.Where(x => x.Level == model.Level).Count() > 0) { ModelState.AddModelError("Error-LevelExists", _translationService.GetResource("Admin.Customers.CustomerReminderLevel.Exists")); } } try { if (ModelState.IsValid) { level = await _customerReminderViewModelService.UpdateReminderLevel(customerReminder, level, model); Success(_translationService.GetResource("Admin.Customers.CustomerReminderLevel.Updated")); return(continueEditing ? RedirectToAction("EditLevel", new { customerReminderId = customerReminder.Id, cid = level.Id }) : RedirectToAction("Edit", new { id = customerReminder.Id })); } await _customerReminderViewModelService.PrepareReminderLevelModel(model, customerReminder); return(View(model)); } catch (Exception exc) { Error(exc); return(RedirectToAction("Edit", new { id = customerReminder.Id })); } }