public async Task <SupplierBlock> ManagerApproval(int supplierBlockId, string verificationCode) { bool check = await _verification.CheckForVerificationCode(supplierBlockId, verificationCode, (int)Enums.VerificationType.Block); var block = FindSupplierBlockById(supplierBlockId); block.SetStatus((int)Enums.BlockStatus.ApprovedManager); if (check) { block.TotallyBlocked(); NotificationArguments NotificationArguments = new NotificationArguments { BodyEmailArgs = new object[] { block.CommercialRegistrationNo, block.CommercialSupplierName }, SubjectEmailArgs = new object[] { }, PanelArgs = new object[] { block.CommercialRegistrationNo, block.CommercialSupplierName }, SMSArgs = new object[] { block.CommercialRegistrationNo, block.CommercialSupplierName } }; NotificationArguments NotificationArgumentsForSupplier = new NotificationArguments { BodyEmailArgs = new object[] { block.CommercialSupplierName, block.ResolutionNumber, block.BlockStartDate.Value.ToShortDateString() }, SubjectEmailArgs = new object[] { }, PanelArgs = new object[] { block.CommercialSupplierName, block.ResolutionNumber, block.BlockStartDate.Value.ToShortDateString() }, SMSArgs = new object[] { block.CommercialSupplierName, block.ResolutionNumber, block.BlockStartDate.Value.ToShortDateString() } }; MainNotificationTemplateModel mainNotificationTemplateModelForSecretary = new MainNotificationTemplateModel(NotificationArguments, $"Block/SecretaryBlockDetails?Id={Util.Encrypt(block.SupplierBlockId)}", NotificationEntityType.Block, block.SupplierBlockId.ToString(), 0); MainNotificationTemplateModel mainNotificationTemplateModelForMonafasatAdmin = new MainNotificationTemplateModel(NotificationArguments, $"Block/DetailsAsync?Id={Util.Encrypt(block.SupplierBlockId)}", NotificationEntityType.Block, block.SupplierBlockId.ToString(), 0); MainNotificationTemplateModel mainNotificationTemplateModelForSupplier = new MainNotificationTemplateModel(NotificationArgumentsForSupplier, $"Block/BlockDetailsAsync?Id={Util.Encrypt(block.SupplierBlockId)}", NotificationEntityType.Block, block.SupplierBlockId.ToString(), 0); MainNotificationTemplateModel mainNotificationTemplateModelForAccountMangerSpecialist = new MainNotificationTemplateModel(NotificationArguments, $"Block/BlockDetailsAsync?Id={Util.Encrypt(block.SupplierBlockId)}", NotificationEntityType.Block, block.SupplierBlockId.ToString(), 0); if (!string.IsNullOrEmpty(block.AgencyCode)) { await _notificationAppService.SendNotificationForUsersByRoleNameAndAgency(NotificationOperations.BlockManager.OperationsToBeApproved.ApproveBlockFromManagerToMonafasatAdmin, RoleNames.MonafasatAdmin, mainNotificationTemplateModelForMonafasatAdmin, block.AgencyCode, block.Agency.CategoryId.Value, null); await _notificationAppService.SendNotificationForUsersByRoleName(NotificationOperations.BlockManager.OperationsToBeApproved.AppoveBlockFromMangerToAccountMangerSpecialist, RoleNames.AccountsManagementSpecialist, mainNotificationTemplateModelForAccountMangerSpecialist); } await _notificationAppService.SendNotificationForSuppliers(NotificationOperations.BlockManager.OperationsToBeApproved.sendApprovedManagerApprovedBlocked, new List <string> { block.CommercialRegistrationNo }, mainNotificationTemplateModelForSupplier); await _notificationAppService.SendNotificationForUsersByRoleName(NotificationOperations.BlockSecrtary.OperationsToBeApproved.ApproveBlockFromManagerToSecretary, RoleNames.MonafasatBlockListSecritary, mainNotificationTemplateModelForSecretary); } SupplierBlock supplierBlock = await _blockCommands.UpdateAsync(block); if (supplierBlock != null) { await _blockQueries.GetAgencyById(block.AgencyCode); } return(supplierBlock); }
public async Task <bool> CheckForVerificationCode(int tenderId, string verificationCodeString, int typeId) { int userId = _httpContextAccessor.HttpContext.User.UserId(); await _tenderQueries.FindVerificationCode(userId, typeId); await _verification.CheckForVerificationCode(tenderId, verificationCodeString, typeId); return(true); }
public async Task Approve(int id, string verificationCode) { await _verification.CheckForVerificationCode(id, verificationCode, (int)Enums.VerificationType.MandatoryList); var entity = await _mandatoryListQueries.Find(id); entity.Approve(); NotificationArguments NotificationArguments = new NotificationArguments { BodyEmailArgs = new object[] { "", entity.DivisionNameAr, entity.DivisionCode }, SubjectEmailArgs = new object[] { }, PanelArgs = new object[] { entity.DivisionNameAr, entity.DivisionCode }, SMSArgs = new object[] { entity.DivisionNameAr, entity.DivisionCode } }; MainNotificationTemplateModel mainNotificationTemplateModel = new MainNotificationTemplateModel(NotificationArguments, $"MandatoryList/Details?id={Util.Encrypt(id)}", NotificationEntityType.MandatoryList, id.ToString()); await _notificationAppService.SendNotificationForUsersByRoleName(NotificationOperations.MandatoryListOfficer.MandatoryListProducts.ApproveMandatoryList, RoleNames.MandatoryListOfficer, mainNotificationTemplateModel); await _mandatoryListCommands.Update(entity); }