public async Task SaveOperationCode(OperationCodeViewModel operationCode) { int Id = string.IsNullOrEmpty(operationCode.IdString) ? 0 : Util.Decrypt(operationCode.IdString); if (Id == 0) { var op = new NotificationOperationCode(operationCode.OperationCode, operationCode.ArabicName, operationCode.EnglishName, operationCode.PanelTemplateAr, operationCode.PanelTemplateEn, operationCode.EmailBodyTemplateAr, operationCode.EmailBodyTemplateEn, operationCode.SmsTemplateAr, operationCode.SmsTemplateEn, operationCode.NotificationCategoryId, operationCode.UserRoleId); await _notifayCommands.AddNotificationOperationCode(op); } else { var opCode = await _iNotificationQuerie.FindNotificationOperationCode(Util.Decrypt(operationCode.IdString)); opCode.UpdateNotificationOperationCode(operationCode.OperationCode, operationCode.ArabicName, operationCode.EnglishName, operationCode.PanelTemplateAr, operationCode.PanelTemplateEn, operationCode.EmailBodyTemplateAr, operationCode.EmailBodyTemplateEn, operationCode.SmsTemplateAr, operationCode.SmsTemplateEn, operationCode.NotificationCategoryId, operationCode.UserRoleId); await _notifayCommands.UpdateNotificationOperationCode(opCode); } await _notifayCommands.SaveChangesAsync(); }
public async Task ShoulSaveOperationCodeSuccess(string idString) { NotificationOperationCode notificationOperationCode = new BranchUserDefaults().ReturnNotificationOperationCode(); OperationCodeViewModel operationCode = new OperationCodeViewModel() { IdString = idString }; _iNotificationQuerie.Setup(q => q.FindNotificationOperationCode(It.IsAny <int>())) .Returns(() => { return(Task.FromResult <NotificationOperationCode>(notificationOperationCode)); }); await _sut.SaveOperationCode(operationCode); _notifayCommands.Verify(m => m.SaveChangesAsync(), Times.Once); }
public async Task <IActionResult> NotificationOperationCodeCreate(string Id = "") { var dataModel = new OperationCodeViewModel(); var roles = await _ApiClient.GetListAsync <LookupModel>("Lookup/GetUserRoles", null); var categories = await _ApiClient.GetListAsync <LookupModel>("Lookup/GetNotificationCategories", null); try { int nId = string.IsNullOrEmpty(Id) ? 0 : Util.Decrypt(Id); if (nId != 0) { dataModel = await _ApiClient.GetAsync <OperationCodeViewModel>("Account/GetNotificationOperationCodebyId/" + nId, null); } dataModel.UserRoles = roles.Select(d => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem { Text = d.Name, Value = d.Id.ToString() }).ToList(); dataModel.Categories = categories.Select(d => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem { Text = d.Name, Value = d.Id.ToString() }).ToList(); return(View(dataModel)); } catch (BusinessRuleException ex) { AddError(ex.Message); return(RedirectToAction("INDEX", "Dashboard")); } catch (AuthorizationException ex) { throw ex; } catch (Exception ex) { _logger.LogError(ex.ToString(), ex); AddError(Resources.TenderResources.ErrorMessages.UnexpectedError); return(RedirectToAction(nameof(Logout))); } }
public async Task <IActionResult> PostNotificationOperationCodeCreate(OperationCodeViewModel model) { try { var profile = await _ApiClient.PostAsync("Account/SaveOperationCode", null, model); return(RedirectToAction("OperationCodes")); } catch (BusinessRuleException ex) { AddError(ex.Message); return(RedirectToAction(nameof(OperationCodes))); } catch (AuthorizationException ex) { throw ex; } catch (Exception ex) { _logger.LogError(ex.ToString(), ex); AddError(Resources.TenderResources.ErrorMessages.UnexpectedError); return(RedirectToAction(nameof(OperationCodes))); } }
public async Task SaveOperationCode([FromBody] OperationCodeViewModel operationCodeViewModel) { await _notificationAppService.SaveOperationCode(operationCodeViewModel); }