public async Task AddUserAsyn(BranchUserModel branchUserModel, string agencyCode) { Check.ArgumentNotNull(nameof(branchUserModel), branchUserModel); var user = await _iDMAppService.FindUserProfileByUserNameAsync(branchUserModel.UserName); if (user != null) { _branchServiceDomain.AssignBranchUserExist(branchUserModel.BranchId, branchUserModel.RoleName, user); } List <IDMRolesModel> roles = _iDMAppService.GetIDMRoles(); IDMRolesModel iDMRolesModel = roles.FirstOrDefault(r => r.Name == branchUserModel.RoleName); branchUserModel.RoleName = iDMRolesModel.Name; branchUserModel.RoleArName = iDMRolesModel.NormalizedName; Enums.UserRole userType = (Enums.UserRole)Enum.Parse(typeof(Enums.UserRole), branchUserModel.RoleName, true); UserProfile userProfile = new UserProfile(); if (user == null) { userProfile = await _iDMAppService.GetUserProfileByEmployeeId(branchUserModel.UserName, agencyCode, userType); Check.ArgumentNotNull(nameof(userProfile), userProfile); await _genericCommandRepository.CreateAsync(userProfile); branchUserModel.UserId = userProfile.Id; } else { var defaultSettingsForUserType = await _notificationAppService.GetDefaultSettingByUserType(userType); if (user.NotificationSetting.Count(x => x.UserRoleId == (int)userType) < defaultSettingsForUserType.Count) { await _branchServiceDomain.CheckUserExist(user.Id, branchUserModel.BranchId, branchUserModel.RoleName); user.AddNotificationSettings(defaultSettingsForUserType); _genericCommandRepository.Update(user); } branchUserModel.UserId = user.Id; } var branchUser = new BranchUser(branchUserModel.BranchId, branchUserModel.UserId, (int)((Enums.UserRole)Enum.Parse(typeof(Enums.UserRole), branchUserModel.RoleName)), branchUserModel.RelatedAgencyCode, branchUserModel.EstimatedValueFrom, branchUserModel.EstimatedValueTo); await _genericCommandRepository.CreateAsync(branchUser); await _genericCommandRepository.SaveAsync(); if (user != null) { if (!string.IsNullOrEmpty(user.Email) || !string.IsNullOrEmpty(user.Mobile)) { await _notificationAppService.SendNotificationByEmailAndSmsForRolesChanged(user.Id, user.Email, user.Mobile); } } else { if (!string.IsNullOrEmpty(userProfile.Email) || !string.IsNullOrEmpty(userProfile.Mobile)) { await _notificationAppService.SendNotificationByEmailAndSmsForRolesChanged(userProfile.Id, userProfile.Email, userProfile.Mobile); } } }
async Task <bool> FinishCompletedBiddingRounds() { List <BiddingRound> biddingRounds = await _tenderQueries.FindFinishedBiddingRounds(); foreach (var round in biddingRounds) { round.UpdateStatus((int)Enums.BiddingRoundStatus.Stopped); _genericCommandRepository.Update(round); } await _genericCommandRepository.SaveAsync(); return(true); }
public async Task <Committee> UpdateAsync(CommitteeModel committeeModel) { Check.ArgumentNotNull(nameof(committeeModel), committeeModel); await _committeeDomainService.CheckNameExist(committeeModel.CommitteeName, committeeModel.AgencyCode, committeeModel.CommitteeId); var committee = await _committeeQueries.GetById(committeeModel.CommitteeId); committee.Update(committeeModel.CommitteeName, committeeModel.Address, committeeModel.Phone, committeeModel.Fax, committeeModel.Email, committeeModel.PostalCode, committeeModel.ZipCode); var result = _genericCommandRepository.Update(committee); await _genericCommandRepository.SaveAsync(); return(result); }
public async Task AddUserToBranchAsyn(BranchUserAssignModel branchUserModel, string agencyCode) { Check.ArgumentNotNull(nameof(branchUserModel), branchUserModel); var user = await _iDMAppService.FindUserProfileByUserNameAsync(branchUserModel.NationalIdString); Enums.UserRole userRole = ((Enums.UserRole)Enum.Parse(typeof(Enums.UserRole), branchUserModel.RoleName)); if (user == null) { ManageUsersAssignationModel emp = await _iDMAppService.GetMonafastatEmployeeDetailById(agencyCode, branchUserModel.NationalIdString, ""); UserProfile userProfile = new UserProfile(emp.userId, emp.nationalId, emp.fullName, emp.mobileNumber, emp.email, await _notificationAppService.GetDefaultSettingByUserType(userRole)); Check.ArgumentNotNull(nameof(userProfile), userProfile); await _genericCommandRepository.CreateAsync(userProfile); branchUserModel.UserId = userProfile.Id; } else { if (!user.NotificationSetting.Any(x => x.UserRoleId == (int)userRole)) { await _branchServiceDomain.CheckUserExist(user.Id, branchUserModel.BranchId, branchUserModel.RoleName); user.AddNotificationSettings(await _notificationAppService.GetDefaultSettingByUserType(userRole)); _genericCommandRepository.Update(user); } branchUserModel.UserId = user.Id; } var branchUser = new BranchUser(branchUserModel.BranchId, branchUserModel.UserId.Value, (int)userRole, branchUserModel.RelatedAgencyCode, branchUserModel.EstimatedValueFrom, branchUserModel.EstimatedValueTo); await _genericCommandRepository.CreateAsync(branchUser); await _genericCommandRepository.SaveAsync(); if (user == null) { if (!string.IsNullOrEmpty(branchUser.UserProfile.Email) || !string.IsNullOrEmpty(branchUser.UserProfile.Mobile)) { await _notificationAppService.SendNotificationByEmailAndSmsForRolesChanged(branchUser.UserProfile.Id, branchUser.UserProfile.Email, branchUser.UserProfile.Mobile); } } else { if (!string.IsNullOrEmpty(user.Email) || !string.IsNullOrEmpty(user.Mobile)) { await _notificationAppService.SendNotificationByEmailAndSmsForRolesChanged(user.Id, user.Email, user.Mobile); } } }
public async Task <bool> UpdateBillThroughTahseel() { var Bills = await _billQueries.GetAllBillInfos(); DateTime expirydate = new DateTime(); if (Bills.Count > 0) { foreach (var bill in Bills) { var billToUpdte = await _billQueries.FindBillByInvoiceNumberWithoutIncludes(bill.BillInvoiceNumber); if (bill.ActionStatus == (int)Enums.BillActionStatus.UpdateBill) { if (bill.ConditionsBookletID != null) { expirydate = bill.ConditionsBooklet.Tender.LastOfferPresentationDate.Value; } else { expirydate = bill.Invitation.Tender.LastOfferPresentationDate.Value; } bill.UpdateExpiryDateWithoutChangeState(expirydate); } var result = await _billProxy.UpdateBillActionStatus(bill); if (result) { if (bill.ActionStatus == (int)Enums.BillActionStatus.UpdateBill) { if (bill.ConditionsBookletID != null) { expirydate = bill.ConditionsBooklet.Tender.LastOfferPresentationDate.Value; } else { expirydate = bill.Invitation.Tender.LastOfferPresentationDate.Value; } billToUpdte.UpdateActionStatusAndExpiryDate(BillActionStatus.SuccessUpdateBill, expirydate); } else { billToUpdte.UpdateActionStatus(BillActionStatus.SuccessCancelBill); } _genericCommandRepository.Update(billToUpdte); } } await _genericCommandRepository.SaveAsync(); return(true); } else { return(false); } }
public async Task FindTendersWithPlaintsAfterStoppingPeriodJob() { List <AgencyCommunicationRequest> agencyCommunications = await _communicationRequestJobQueries.FindTendersWithPlaintsAfterStoppingPeriodJob(); var agencyCodeList = agencyCommunications.Select(d => d.Tender.AgencyCode).Distinct().ToList(); var agencies = await _communicationRequestJobQueries.FindAgenciesByAgencyCodes(agencyCodeList); int?agencyCategoryId = 0; foreach (var request in agencyCommunications) { if (request.PlaintNotification == null) { continue; } PlaintRequestNotification obj = request.PlaintNotification; obj.Update(true); _genericCommandRepository.Update(obj); await _genericCommandRepository.SaveAsync(); agencyCategoryId = agencies.Where(a => a.AgencyCode == request.Tender.AgencyCode).FirstOrDefault().CategoryId; NotificationArguments NotificationArguments = new NotificationArguments { BodyEmailArgs = new object[] { "", request.PlaintAcceptanceStatus.Name, request.Tender.ReferenceNumber }, SubjectEmailArgs = new object[] { }, PanelArgs = new object[] { request.Tender.ReferenceNumber }, SMSArgs = new object[] { request.Tender.ReferenceNumber } }; MainNotificationTemplateModel approveTender = new MainNotificationTemplateModel(NotificationArguments, $"Tender/Details?STenderId{Util.Encrypt(request.Tender.TenderId)}", NotificationEntityType.Tender, request.Tender.TenderId.ToString(), request.Tender.BranchId); if (request.Tender.TenderTypeId == (int)Enums.TenderType.NewDirectPurchase) { await _notificationJobAppService.SendNotifications(NotificationOperations.DirectPurchaseSecretary.AgencyCommunicationRequest.PlaintStoppingPeriodEnd, request.Tender.AgencyCode, agencyCategoryId.Value, approveTender, Enums.UserRole.NewMonafasat_SecretaryDirtectPurshasingCommittee.ToString(), (int)request.Tender.DirectPurchaseCommitteeId); } else { await _notificationJobAppService.SendNotifications(NotificationOperations.OffersCheckSecretary.AgencyCommunicationRequest.PlaintStoppingPeriodEnd, request.Tender.AgencyCode, agencyCategoryId.Value, approveTender, Enums.UserRole.NewMonafasat_OffersCheckSecretary.ToString(), (int)request.Tender.OffersCheckingCommitteeId); } } }
public async Task <PrePlanningModel> CreateAsync(PrePlanningModel model) { Check.ArgumentNotNull(nameof(model), model); PrePlanning planning; await _prePlanningDomainService.CheckNameExist(model.ProjectName, model.BranchId, model.YearQuarterId, model.AgencyCode, model.PrePlanningId); if (model.PrePlanningId == 0) { planning = new PrePlanning(model.PrePlanningId, model.AgencyCode, model.BranchId, model.ProjectName, model.ProjectNature, model.ProjectTypeId, model.ProjectDescription, model.InsideKSA, (int)Enums.PrePlanningStatus.UnderUpdate, model.Duration, model.DurationInDays, model.DurationInMonths, model.DurationInYears, model.YearQuarterId); planning.IsDurationValid(); planning.AddtAreasCountriesTypes(model.PrePlanningAreaIDs, model.InsideKSA, model.PrePlanningCountriesIDs, model.ProjectTypesIDs); planning = await _genericCommandRepository.CreateAsync <PrePlanning>(planning); } else { planning = await _prePlanningQueries.FindByIdForEdit(model.PrePlanningId); if (planning.StatusId == (int)Enums.PrePlanningStatus.Pending || planning.StatusId == (int)Enums.PrePlanningStatus.Rejected) { throw new UnHandledAccessException(); } planning.Update(model.AgencyCode, model.ProjectName, model.ProjectNature, model.ProjectDescription, model.InsideKSA, (int)Enums.PrePlanningStatus.UnderUpdate, model.Duration, model.DurationInDays, model.DurationInMonths, model.DurationInYears, model.YearQuarterId); planning.IsDurationValid(); planning = planning.UpdatetAreasCountriesTypes(model.PrePlanningAreaIDs, model.InsideKSA, model.PrePlanningCountriesIDs, model.ProjectTypesIDs); _genericCommandRepository.Update <PrePlanning>(planning); } await _genericCommandRepository.SaveAsync(); model.PrePlanningId = planning.PrePlanningId; return(model); }
public async Task <bool> updateAnnouncementListStatus() { var announcements = await _announcementQueires.getAllEndedTemplates(); foreach (var announcement in announcements) { announcement.UpdateAnnouncementStatus(Enums.AnnouncementSupplierTemplateStatus.Ended, "", 0); _genericCommandRepository.Update(announcement); } await _genericCommandRepository.SaveAsync(); return(true); }
public async Task SendFinalAwardedTendersToEmarketPlace() { var tenders = await _tenderQueries.GetAllFinalAwardedTendersForEmarketPlace(); if (tenders.Any()) { foreach (var tender in tenders) { var awardedTenderOffers = tender.Offers.Where(x => x.IsActive == true && (x.TotalOfferAwardingValue != null || x.PartialOfferAwardingValue != null)).ToList(); if (awardedTenderOffers.Any()) { var isSentToEmarketPlace = await SendToEmarketPlace(awardedTenderOffers.Select(o => o.OfferId).ToList()); if (isSentToEmarketPlace) { tender.UpdateEmarketPlaceStatus(); _genericCommandRepository.Update(tender); } } } await _genericCommandRepository.SaveAsync(); } }
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 Update(ModelViewModel modelViewModel) { var model = mapper.Map <Model>(modelViewModel); modelCommandRepository.Update(model); }
public void Update(FieldViewModel fieldViewModel) { var field = mapper.Map <Field>(fieldViewModel); fieldCommandRepository.Update(field); }
public void Update(SourceViewModel sourceViewModel) { var source = mapper.Map <Source>(sourceViewModel); sourceCommandRepository.Update(source); }