public async Task <SupplierBlock> ManagerRejectionReason(int supplierBlockId, string reason) { var block = FindSupplierBlockById(supplierBlockId); block.SetManagerRejectionReason(reason); SupplierBlock supplierBlock = await _blockCommands.UpdateAsync(block); if (supplierBlock != null) { 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 } }; 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); await _notificationAppService.SendNotificationForUsersByRoleName(NotificationOperations.BlockSecrtary.OperationsToBeApproved.sendRejectBlockToSecretary, RoleNames.MonafasatBlockListSecritary, mainNotificationTemplateModelForSecretary); if (!string.IsNullOrEmpty(block.AgencyCode)) { await _notificationAppService.SendNotificationForUsersByRoleNameAndAgency(NotificationOperations.BlockMonafasatAdmin.OperationsRequest.sendRejectBlockToMonafasatAdmin, RoleNames.MonafasatAdmin, mainNotificationTemplateModelForMonafasatAdmin, block.AgencyCode, block.Agency.CategoryId.Value, null); } } return(supplierBlock); }
public async Task <SupplierBlock> UpdateAsync(SupplierBlock block) { _context.SupplierBlock.Update(block); await _context.SaveChangesAsync(); return(block); }
public async Task <SupplierBlock> AddAdminBlock(SupplierBlockModel blockModel) { SupplierBlock block = new SupplierBlock(blockModel.CommercialRegistrationNo, blockModel.CommercialSupplierName, blockModel.ResolutionNumber, blockModel.BlockStatusId, 2, blockModel.AgencyCode, blockModel.BlockStartDate, blockModel.BlockEndDate, blockModel.Punishment, blockModel.BlockDetails, blockModel.AdminFileName, blockModel.AdminFileNetReferenceId, blockModel.SecretaryFileName, blockModel.SecretaryFileNetReferenceId, blockModel.AdminBlockReason, blockModel.SecretaryBlockReason, blockModel.SupplierTypeId, blockModel.OrganizationTypeId, blockModel.CommercialRegistrationNo, blockModel.CommercialRegistrationNo, false); string crNumber = blockModel.CommercialRegistrationNo; var supplier = await _supplierQueries.FindSupplierByCRNumber(crNumber); if (supplier == null) { Supplier supplierobj = new Supplier(crNumber, blockModel.CommercialSupplierName, await _notificationAppService.GetDefaultSettingByCr()); await _genericrepository.CreateAsync <Supplier>(supplierobj); } else { List <UserNotificationSetting> defaultNotificationSettings = await _notificationAppService.GetDefaultSettingByCr(); supplier.AddNotificationSettings(defaultNotificationSettings); _genericrepository.Update(supplier); } QueryResult <SupplierBlockModel> supplierBlock = await _blockQueries.FindBlockedUser(new BlockSearchCriteria { AgencyCode = block.AgencyCode, CommercialRegistrationNo = block.CommercialRegistrationNo, EnabledSearchByDate = blockModel.EnabledSearchByDate }); if (supplierBlock != null && supplierBlock.TotalCount > 0) { if (supplierBlock.Items.FirstOrDefault().BlockStatusId == (int)Enums.BlockStatus.NewAdmin || supplierBlock.Items.FirstOrDefault().BlockStatusId == (int)Enums.BlockStatus.NewSecretary || supplierBlock.Items.FirstOrDefault().BlockStatusId == (int)Enums.BlockStatus.ApprovedSecertary) { throw new BusinessRuleException(Resources.BlockResources.Messages.BlockPendingRequest); } else { throw new BusinessRuleException(Resources.BlockResources.ErrorMessages.AlreadyBlocked); } } Check.ArgumentNotNull(nameof(SupplierBlock), block); var res = await _genericrepository.CreateAsync(block); await _genericrepository.SaveAsync(); NotificationArguments NotificationArguments = new NotificationArguments { BodyEmailArgs = new object[] { blockModel.CommercialSupplierName }, SubjectEmailArgs = new object[] { }, PanelArgs = new object[] { blockModel.CommercialSupplierName }, SMSArgs = new object[] { blockModel.CommercialSupplierName } }; if (blockModel.IsSecretaryNotify) { MainNotificationTemplateModel mainNotificationTemplateModelForManger = new MainNotificationTemplateModel(NotificationArguments, $"Block/ManagerBlockDetails?Id={Util.Encrypt(block.SupplierBlockId)}", NotificationEntityType.Block, blockModel.SupplierBlockId.ToString(), 0); await _notificationAppService.SendNotificationForUsersByRoleName(NotificationOperations.BlockManager.OperationsToBeApproved.ApproveBlockManager, RoleNames.MonafasatBlackListCommittee, mainNotificationTemplateModelForManger); } else { MainNotificationTemplateModel mainNotificationTemplateModelForSecretary = new MainNotificationTemplateModel(NotificationArguments, $"Block/SecretaryBlockDetails?Id={Util.Encrypt(block.SupplierBlockId)}", NotificationEntityType.Block, block.SupplierBlockId.ToString(), 0); await _notificationAppService.SendNotificationForUsersByRoleName(NotificationOperations.BlockMonafasatAdmin.OperationsRequest.SendRequestBlockFromMonafasatAdminToBlockSecrtary, RoleNames.MonafasatBlockListSecritary, mainNotificationTemplateModelForSecretary); } return(res); }
public SupplierBlock ReturnSupplierBlockDefaults() { var generalSupplierBlockData = new SupplierBlock("1234", "SelectedCr1", "1", 1, 1, "5678", DateTime.Now.AddDays(1), DateTime.Now.AddDays(4), "Punishment", "Offitial bases defimation", "File Name", "File Net Reference ID", "Secretarry File Name", "Secertary File Name Ref Id", "reason", "secertary Block Reason", 1, 1, "9876543221", "origin", true); generalSupplierBlockData.SetAgencyForTest(); return(generalSupplierBlockData); }
public void Should_DeActive() { var supplierBlock = new SupplierBlock(commercialRegistrationNo, commercialSupplierName, resolutionNumber, blockStatusId, blockTypeId, agencyId, _blockStartDate, _blockEndDate, punishment, blockDetails, adminfileName, adminFileNetReferenceId, secretaryFileName, secretaryFileNetReferenceId, adminBlockreason, secretaryBlockReason, supplierTypeId, organizationTypeId, licenseNumber, commertialRegistrationNoOrigin, isOldBlock); supplierBlock.DeActive(); supplierBlock.ShouldNotBeNull(); supplierBlock.IsActive.ShouldNotBeNull(); supplierBlock.IsActive.Value.ShouldBeFalse(); }
public void Should_SetSecretaryRejectionReason() { var secretaryRejectionReason = "reason updated"; var supplierBlock = new SupplierBlock(commercialRegistrationNo, commercialSupplierName, resolutionNumber, blockStatusId, blockTypeId, agencyId, _blockStartDate, _blockEndDate, punishment, blockDetails, adminfileName, adminFileNetReferenceId, secretaryFileName, secretaryFileNetReferenceId, adminBlockreason, secretaryBlockReason, supplierTypeId, organizationTypeId, licenseNumber, commertialRegistrationNoOrigin, isOldBlock); supplierBlock.SetSecretaryRejectionReason(secretaryRejectionReason); supplierBlock.ShouldNotBeNull(); supplierBlock.SecretaryRejectionReason.ShouldBe(secretaryRejectionReason); supplierBlock.BlockStatusId.ShouldBe((int)Enums.BlockStatus.RejectedSecertary); }
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 void Should_Construct_SupplierBlock() { var supplierBlock = new SupplierBlock(commercialRegistrationNo, commercialSupplierName, resolutionNumber, blockStatusId, blockTypeId, agencyId, _blockStartDate, _blockEndDate, punishment, blockDetails, adminfileName, adminFileNetReferenceId, secretaryFileName, secretaryFileNetReferenceId, adminBlockreason, secretaryBlockReason, supplierTypeId, organizationTypeId, licenseNumber, commertialRegistrationNoOrigin, isOldBlock); supplierBlock.ShouldNotBeNull(); supplierBlock.CommercialRegistrationNo.ShouldBe(commercialRegistrationNo); supplierBlock.CommercialSupplierName.ShouldBe(commercialSupplierName); supplierBlock.ResolutionNumber.ShouldBe(resolutionNumber); supplierBlock.BlockStatusId.ShouldBe(blockStatusId); supplierBlock.BlockTypeId.ShouldBe(blockTypeId); supplierBlock.AgencyCode.ShouldBe(agencyId); supplierBlock.BlockStartDate.ShouldBe(_blockStartDate); supplierBlock.BlockEndDate.ShouldBe(_blockEndDate); supplierBlock.Punishment.ShouldBe(punishment); supplierBlock.BlockDetails.ShouldBe(blockDetails); supplierBlock.AdminFileName.ShouldBe(adminfileName); supplierBlock.AdminFileNetReferenceId.ShouldBe(adminFileNetReferenceId); supplierBlock.AdminBlockReason.ShouldBe(adminBlockreason); supplierBlock.SecretaryFileName.ShouldBe(secretaryFileName); supplierBlock.SecretaryFileNetReferenceId.ShouldBe(secretaryFileNetReferenceId); supplierBlock.SecretaryBlockReason.ShouldBe(secretaryBlockReason); supplierBlock.SupplierTypeId.ShouldBe(supplierTypeId); supplierBlock.OrganizationTypeId.ShouldBe(organizationTypeId); supplierBlock.LicenseNumber.ShouldBe(licenseNumber); supplierBlock.CommertialRegistrationNoOrigin.ShouldBe(commertialRegistrationNoOrigin); supplierBlock.IsOldBlock.ShouldBe(isOldBlock); }
public async Task <IActionResult> AddBlock([FromBody] SupplierBlockModel blockModel) { if (User.UserRole() == RoleNames.MonafasatAdmin) { blockModel.AgencyCode = User.UserAgency(); } else if (User.UserRole() == RoleNames.MonafasatBlackListCommittee || User.UserRole() == RoleNames.MonafasatBlockListSecritary) { blockModel.AgencyCode = null; } blockModel.BranchId = User.UserBranch(); if (blockModel.IsOldSystem == true) { blockModel.BlockStatusId = (int)Enums.BlockStatus.ApprovedManager; } var block = new SupplierBlock(blockModel.CommercialRegistrationNo, blockModel.CommercialSupplierName, blockModel.ResolutionNumber, (int)Enums.BlockStatus.ApprovedManager, blockModel.BlockTypeId, blockModel.AgencyCode, blockModel.BlockStartDate, blockModel.BlockEndDate, blockModel.Punishment, blockModel.BlockDetails, blockModel.FileName, blockModel.FileNetReferenceId, blockModel.SecretaryFileName, blockModel.SecretaryFileNetReferenceId, blockModel.AdminBlockReason, blockModel.SecretaryBlockReason, blockModel.SupplierTypeId, blockModel.OrganizationTypeId, null, null, true); var result = await _blockService.AddBlockAsyn(block); return(Ok(result)); }
public async Task <SupplierBlock> AddBlockAsyn(SupplierBlock block) { var supplier = await _supplierQueries.FindSupplierByCRNumber(block.CommercialRegistrationNo); if (supplier == null) { var supplierobj = new Supplier(block.CommercialRegistrationNo, block.CommercialSupplierName, await _notificationAppService.GetDefaultSettingByCr()); await _genericrepository.CreateAsync(supplierobj); } else { List <UserNotificationSetting> defaultNotificationSettings = await _notificationAppService.GetDefaultSettingByCr(); if (supplier.NotificationSetting.Count < defaultNotificationSettings.Count) { supplier.AddNotificationSettings(defaultNotificationSettings); _genericrepository.Update(supplier); } } if (block.BlockTypeId == 1) { if (block.BlockStartDate != null && block.BlockStartDate != DateTime.MinValue && block.BlockStartDate < DateTime.Now) { throw new BusinessRuleException(Resources.BlockResources.ErrorMessages.PermanentDateValidate); } } else { if (block.BlockEndDate != null && block.BlockEndDate != DateTime.MinValue && block.BlockEndDate < DateTime.Now) { throw new BusinessRuleException(Resources.BlockResources.ErrorMessages.DateValidation); } } QueryResult <SupplierBlockModel> supplierBlock = await _blockQueries.FindBlockedUser(new BlockSearchCriteria { AgencyCode = block.AgencyCode, CommercialRegistrationNo = block.CommercialRegistrationNo, BlockStatusId = (int)IsActive.Active }); if (supplierBlock != null && supplierBlock.TotalCount > 0) { if (supplierBlock.Items.FirstOrDefault().BlockStatusId == (int)Enums.BlockStatus.NewAdmin || supplierBlock.Items.FirstOrDefault().BlockStatusId == (int)Enums.BlockStatus.NewSecretary || supplierBlock.Items.FirstOrDefault().BlockStatusId == (int)Enums.BlockStatus.ApprovedSecertary) { throw new BusinessRuleException(Resources.BlockResources.Messages.BlockPendingRequest); } else { throw new BusinessRuleException(Resources.BlockResources.ErrorMessages.AlreadyBlocked); } } Check.ArgumentNotNull(nameof(SupplierBlock), block); var res = await _genericrepository.CreateAsync(block); await _genericrepository.SaveAsync(); 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 }, SubjectEmailArgs = new object[] { }, PanelArgs = new object[] { block.CommercialSupplierName }, SMSArgs = new object[] { block.CommercialSupplierName } }; MainNotificationTemplateModel mainNotificationTemplateModelForSecretary = new MainNotificationTemplateModel(NotificationArguments, $"Block/SecretaryBlockDetails?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); await _notificationAppService.SendNotificationForSuppliers(NotificationOperations.BlockManager.OperationsToBeApproved.sendApprovedManagerApprovedBlocked, new List <string> { block.CommercialRegistrationNo }, mainNotificationTemplateModelForSupplier); await _notificationAppService.SendNotificationForUsersByRoleName(NotificationOperations.BlockSecrtary.OperationsToBeApproved.ApproveBlockFromManagerToSecretary, RoleNames.MonafasatBlockListSecritary, mainNotificationTemplateModelForSecretary); await _notificationAppService.SendNotificationForUsersByRoleName(NotificationOperations.BlockManager.OperationsToBeApproved.AppoveBlockFromMangerToAccountMangerSpecialist, RoleNames.AccountsManagementSpecialist, mainNotificationTemplateModelForAccountMangerSpecialist); return(res); }
public void Should_UpdateBlock() { var updatedcommercialRegistrationNo = "updated"; var updatedcommercialSupplierName = "updated"; var updatedresolutionNumber = "updated"; var updatedblockStatusId = 3; var updatedagencyId = "updated"; DateTime?updatedblockStartDate = DateTime.Today.AddDays(4); DateTime?updatedblockEndDate = DateTime.Today.AddDays(6); var updatedpunishment = "updated"; var updatedadminfileName = "updated"; var updatedadminFileNetReferenceId = "updated"; var updatedsecretaryFileName = "updated"; var updatedsecretaryFileNetReferenceId = "updated"; var updatedadminBlockreason = "updated"; var updatedsecretaryBlockReaso = "updated"; var supplierBlock = new SupplierBlock(commercialRegistrationNo, commercialSupplierName, resolutionNumber, blockStatusId, blockTypeId, agencyId, _blockStartDate, _blockEndDate, punishment, blockDetails, adminfileName, adminFileNetReferenceId, secretaryFileName, secretaryFileNetReferenceId, adminBlockreason, secretaryBlockReason, supplierTypeId, organizationTypeId, licenseNumber, commertialRegistrationNoOrigin, isOldBlock); supplierBlock.UpdateBlock(updatedcommercialRegistrationNo, updatedcommercialSupplierName, updatedresolutionNumber, updatedblockStatusId, updatedagencyId, updatedblockStartDate, updatedblockEndDate, updatedpunishment, updatedadminfileName, updatedadminFileNetReferenceId, updatedsecretaryFileName, updatedsecretaryFileNetReferenceId, updatedadminBlockreason, updatedsecretaryBlockReaso); supplierBlock.ShouldNotBeNull(); supplierBlock.CommercialRegistrationNo.ShouldBe(updatedcommercialRegistrationNo); supplierBlock.CommercialSupplierName.ShouldBe(updatedcommercialSupplierName); supplierBlock.ResolutionNumber.ShouldBe(updatedresolutionNumber); supplierBlock.BlockStatusId.ShouldBe(updatedblockStatusId); supplierBlock.AgencyCode.ShouldBe(updatedagencyId); supplierBlock.BlockStartDate.ShouldBe(updatedblockStartDate); supplierBlock.BlockEndDate.ShouldBe(updatedblockEndDate); supplierBlock.Punishment.ShouldBe(updatedpunishment); supplierBlock.AdminFileName.ShouldBe(updatedadminfileName); supplierBlock.AdminFileNetReferenceId.ShouldBe(updatedadminFileNetReferenceId); supplierBlock.AdminBlockReason.ShouldBe(updatedadminBlockreason); supplierBlock.SecretaryFileName.ShouldBe(updatedsecretaryFileName); supplierBlock.SecretaryFileNetReferenceId.ShouldBe(updatedsecretaryFileNetReferenceId); supplierBlock.SecretaryBlockReason.ShouldBe(updatedsecretaryBlockReaso); supplierBlock.IsActive.ShouldBe(true); }