private void IsValidToAddEditDescriptionAndConditionsTemplate(Tender tender, EditConditionTemplateEighthSectionModel model, bool ValidatationFromNextStep = false) { List <int> listOfSections = Array.ConvertAll(model.ListOfSections.Split(','), int.Parse).ToList(); List <int> ListOfTemplateIds = Array.ConvertAll(model.TemplateIds.Split(','), int.Parse).ToList(); if (tender.ConditionTemplateStageStatusId != (int)Enums.TenderConditoinsStatus.Specifications) { throw new BusinessRuleException(Resources.TenderResources.ErrorMessages.MustFillPreviousInformation); } if (listOfSections.Contains((int)Enums.ConditionsTemplateSections.WorkForce)) { if (ListOfTemplateIds.Count == 1 && ListOfTemplateIds.FirstOrDefault() != (int)Enums.ConditionsTemplateCategory.GeneralSuppliesSupply) { if ((!ValidatationFromNextStep && string.IsNullOrEmpty(model?.WorkforceSpecifications)) || (ValidatationFromNextStep && string.IsNullOrEmpty(tender.TenderConditionsTemplate?.WorkforceSpecifications))) { var value = Resources.TenderResources.DisplayInputs.WorkforceSpecifications; throw new BusinessRuleException(Resources.TenderResources.DisplayInputs.PleaseEnterValueOf + value); } } } if (listOfSections.Contains((int)Enums.ConditionsTemplateSections.Materials)) { if ((!ValidatationFromNextStep && string.IsNullOrEmpty(model?.MaterialsSpecifications)) || (ValidatationFromNextStep && string.IsNullOrEmpty(tender.TenderConditionsTemplate?.MaterialsSpecifications))) { var value = Resources.TenderResources.DisplayInputs.MaterialsSpecifications; throw new BusinessRuleException(Resources.TenderResources.DisplayInputs.PleaseEnterValueOf + value); } } if (listOfSections.Contains((int)Enums.ConditionsTemplateSections.Equipments)) { if ((!ValidatationFromNextStep && string.IsNullOrEmpty(model?.EquipmentsSpecifications)) || (ValidatationFromNextStep && string.IsNullOrEmpty(tender.TenderConditionsTemplate?.EquipmentsSpecifications))) { var value = Resources.TenderResources.DisplayInputs.EquipmentsSpecifications; throw new BusinessRuleException(Resources.TenderResources.DisplayInputs.PleaseEnterValueOf + value); } } if ((!ValidatationFromNextStep && string.IsNullOrEmpty(model?.QualitySpecifications)) || (ValidatationFromNextStep && string.IsNullOrEmpty(tender.TenderConditionsTemplate?.QualitySpecifications))) { var value = Resources.TenderResources.DisplayInputs.QualitySpecifications; throw new BusinessRuleException(Resources.TenderResources.DisplayInputs.PleaseEnterValueOf + value); } if ((!ValidatationFromNextStep && string.IsNullOrEmpty(model?.SafetySpecifications)) || (ValidatationFromNextStep && string.IsNullOrEmpty(tender.TenderConditionsTemplate?.SafetySpecifications))) { var value = Resources.TenderResources.DisplayInputs.SafetySpecifications; throw new BusinessRuleException(Resources.TenderResources.DisplayInputs.PleaseEnterValueOf + value); } }
public async Task AddEditDescriptionAndConditionsTemplate(EditConditionTemplateEighthSectionModel model, int branchId) { Tender tender = await _tenderQueries.FindTenderWithConditionsTemplateById(Util.Decrypt(model.EncryptedTenderId), branchId); if (tender == null) { throw new UnHandledAccessException(Resources.SharedResources.ErrorMessages.YouHaveNoAccess); } var versionId = await _tenderQueries.GetCurrentTenderActivityVersion(tender.TenderId); IsValidToAddEditDescriptionAndConditionsTemplate(tender, model); if (versionId < (int)Enums.ActivityVersions.Sprint7Activities) { var hasInvitation = ((tender.PreQualificationId != null || tender.TenderTypeId == (int)Enums.TenderType.SecondStageTender || tender.TenderTypeId == (int)Enums.TenderType.NewDirectPurchase || tender.TenderTypeId == (int)Enums.TenderType.ReverseBidding || tender.TenderTypeId == (int)Enums.TenderType.LimitedTender || tender.TenderTypeId == (int)Enums.TenderType.FrameworkAgreement || tender.TenderTypeId == (int)Enums.TenderType.Competition || tender.TenderTypeId == (int)Enums.TenderType.NationalTransformationProjects) && tender.InvitationTypeId == (int)Enums.InvitationType.Specific) || (tender.TenderTypeId == (int)Enums.TenderType.CurrentDirectPurchase && tender.OfferPresentationWayId == (int)Enums.OfferPresentationWayId.TwoSepratedFiles); if (!hasInvitation) { tender.UpdateTenderStatus(Enums.TenderStatus.Established, "", _httpContextAccessor.HttpContext.User.UserId(), TenderActions.CreateTender); } else { tender.UpdateTenderStatus(Enums.TenderStatus.UnderEstablishing); } } var tenderAttachments = new List <TenderAttachment>(); foreach (var item in model.TenderAttachments) { tenderAttachments.Add(new TenderAttachment(item.Name, item.FileNetReferenceId, item.AttachmentTypeId, null, null)); } tender.UpdateAttachments(tenderAttachments, _httpContextAccessor.HttpContext.User.UserId()); var hasMaterialInformation = tender.TenderActivities.Count == 1 && tender.TenderActivities.FirstOrDefault().Activity.ActivityTemplateVersions.Any(t => t.TemplateId == (int)Enums.TenderActivityTamplate.MedicalMaterials); tender.TenderConditionsTemplate.UpdateConditionsTemplateEighthStep(model.WorkforceSpecifications, model.MaterialsSpecifications, model.SpecialConditions, model.Attachments, model.EquipmentsSpecifications, model.ContractBasedOnPerformanceDetails, model.QualitySpecifications, model.SafetySpecifications, model.BasicInformation, model.RequiredDcoumentationBefore, model.Tests, model.IntilizationAndStartWork, model.RequiredDcoumentationAfter, model.Trainging, model.Guarantee, model.Maintanance, model.MachineGuarantee, model.MachineMaintanance, hasMaterialInformation ); await _tenderCommands.UpdateAsync(tender); }
public void IsValidToUpdateConditionsTemplateEighthStep(Tender tender, EditConditionTemplateEighthSectionModel model, bool ValidatationFromNextStep = false) { var ShowGeneralOnly = tender.TenderActivities.Where(a => a.IsActive == true).Select(a => a.Activity.Activitytemplate.ActivitytemplatId).Distinct().Count() > 1; IsValidToUpdateConditionsTemplateSeventhStep(tender, null, true); var listOfSections = tender.TenderActivities.SelectMany(a => a.Activity.Activitytemplate.ConditionTemplateActivities).Select(a => a.ConditionsTemplateSectionId).Distinct().ToList(); if (!(tender.ConditionTemplateStageStatusId == (int)Enums.TenderConditoinsStatus.Specifications)) { throw new BusinessRuleException(Resources.TenderResources.ErrorMessages.MustFillPreviousInformation); } if (listOfSections.Contains((int)Enums.ConditionsTemplateSections.WorkForce)) { if ((!ValidatationFromNextStep && string.IsNullOrEmpty(model?.WorkforceSpecifications)) || (ValidatationFromNextStep && string.IsNullOrEmpty(tender.TenderConditionsTemplate?.WorkforceSpecifications))) { var value = Resources.TenderResources.DisplayInputs.WorkforceSpecifications; throw new BusinessRuleException(Resources.TenderResources.DisplayInputs.PleaseEnterValueOf + value); } } if (listOfSections.Contains((int)Enums.ConditionsTemplateSections.Materials)) { if ((!ValidatationFromNextStep && string.IsNullOrEmpty(model?.MaterialsSpecifications)) || (ValidatationFromNextStep && string.IsNullOrEmpty(tender.TenderConditionsTemplate?.MaterialsSpecifications))) { var value = Resources.TenderResources.DisplayInputs.MaterialsSpecifications; throw new BusinessRuleException(Resources.TenderResources.DisplayInputs.PleaseEnterValueOf + value); } } if (listOfSections.Contains((int)Enums.ConditionsTemplateSections.Equipments)) { if ((!ValidatationFromNextStep && string.IsNullOrEmpty(model?.EquipmentsSpecifications)) || (ValidatationFromNextStep && string.IsNullOrEmpty(tender.TenderConditionsTemplate?.EquipmentsSpecifications))) { var value = Resources.TenderResources.DisplayInputs.EquipmentsSpecifications; throw new BusinessRuleException(Resources.TenderResources.DisplayInputs.PleaseEnterValueOf + value); } } if (listOfSections.Contains((int)Enums.ConditionsTemplateSections.ImplementaionMethod)) { if ((!ValidatationFromNextStep && string.IsNullOrEmpty(model?.ServicesAndWorkImplementationsMethod)) || (ValidatationFromNextStep && string.IsNullOrEmpty(tender.TenderConditionsTemplate?.ServicesAndWorkImplementationsMethod))) { var value = Resources.TenderResources.DisplayInputs.ServicesAndWorkImplementationsMethod; throw new BusinessRuleException(Resources.TenderResources.DisplayInputs.PleaseEnterValueOf + value); } } if (listOfSections.Contains((int)Enums.ConditionsTemplateSections.QualityDescription)) { if ((!ValidatationFromNextStep && string.IsNullOrEmpty(model?.QualitySpecifications)) || (ValidatationFromNextStep && string.IsNullOrEmpty(tender.TenderConditionsTemplate?.QualitySpecifications))) { var value = Resources.TenderResources.DisplayInputs.QualitySpecifications; throw new BusinessRuleException(Resources.TenderResources.DisplayInputs.PleaseEnterValueOf + value); } } if (listOfSections.Contains((int)Enums.ConditionsTemplateSections.SafteyDescription)) { if ((!ValidatationFromNextStep && string.IsNullOrEmpty(model?.SafetySpecifications)) || (ValidatationFromNextStep && string.IsNullOrEmpty(tender.TenderConditionsTemplate?.SafetySpecifications))) { var value = Resources.TenderResources.DisplayInputs.SafetySpecifications; throw new BusinessRuleException(Resources.TenderResources.DisplayInputs.PleaseEnterValueOf + value); } } }