public async Task <ApiResponse> Handle(AddEditEligibilityCriteriaDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); EligibilityCriteriaDetail _detail = new EligibilityCriteriaDetail(); try { _detail = await _dbContext.EligibilityCriteriaDetail.FirstOrDefaultAsync(x => x.ProjectId == request.ProjectId && x.IsDeleted == false); if (_detail == null) { _detail = new EligibilityCriteriaDetail { DonorCriteriaMet = request.DonorCriteriaMet, EligibilityDealine = request.EligibilityDealine, CoPartnership = request.CoPartnership, ProjectId = request.ProjectId, IsDeleted = false, CreatedById = request.CreatedById, CreatedDate = DateTime.UtcNow }; await _dbContext.EligibilityCriteriaDetail.AddAsync(_detail); await _dbContext.SaveChangesAsync(); } else { _detail.DonorCriteriaMet = request.DonorCriteriaMet; _detail.EligibilityDealine = request.EligibilityDealine; _detail.CoPartnership = request.CoPartnership; _detail.ProjectId = request.ProjectId; _detail.IsDeleted = false; _detail.ModifiedById = request.ModifiedById; _detail.ModifiedDate = DateTime.UtcNow; await _dbContext.SaveChangesAsync(); } response.data.eligibilityCriteriaDetail = _detail; response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public string PostUpdateEligibleCriteria(List <PostEligibilityCriteria> lstpostAssessmentModal) { string result = "Failed"; try { Guid AssesmentEligibilityId = Guid.NewGuid(); using (DBEntities TestEngineDBContext = new DBEntities()) { List <EligibilityCriteriaDetail> lstEligibilityCriteriaDetail = new List <EligibilityCriteriaDetail>(); foreach (var item in lstpostAssessmentModal) { EligibilityCriteriaDetail eligibilityCriteriaDetail = new EligibilityCriteriaDetail(); eligibilityCriteriaDetail.ID = item.EligibilityGuid; eligibilityCriteriaDetail.MayConsider = item.MayConsider; eligibilityCriteriaDetail.Name = item.Name; eligibilityCriteriaDetail.NotConsider = item.NotConsider; eligibilityCriteriaDetail.StrongConsider = item.StrongConsider; eligibilityCriteriaDetail.QuestionBankID = item.QuestionBankID; eligibilityCriteriaDetail.EligibilityIdForAssessment = AssesmentEligibilityId; lstEligibilityCriteriaDetail.Add(eligibilityCriteriaDetail); } if (lstEligibilityCriteriaDetail.Any()) { var eligilibilityCriteriaName = lstEligibilityCriteriaDetail.FirstOrDefault().Name; var eligibilityCritAvailability = TestEngineDBContext.EligibilityCriteriaDetails.FirstOrDefault(x => x.Name == eligilibilityCriteriaName); if (eligibilityCritAvailability == null) { TestEngineDBContext.EligibilityCriteriaDetails.AddRange(lstEligibilityCriteriaDetail); TestEngineDBContext.SaveChanges(); result = AssesmentEligibilityId.ToString(); } else { result = "ALREADY AVAILABLE"; } } } } catch (Exception ex) { throw ex; } return(result); }