public async Task <ApiResponse> Handle(AddFeasibleExpertOtherDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { CEFeasibilityExpertOtherDetail _detail = new CEFeasibilityExpertOtherDetail { ExpertOtherDetailId = request.ExpertOtherDetailId.Value, Name = request.Name, ProjectId = request.ProjectId, IsDeleted = false, CreatedById = request.CreatedById, CreatedDate = DateTime.UtcNow }; await _dbContext.CEFeasibilityExpertOtherDetail.AddAsync(_detail); await _dbContext.SaveChangesAsync(); response.CommonId.LongId = _detail.ExpertOtherDetailId; response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(EditFeasibilityExpertDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { CEFeasibilityExpertOtherDetail _detail = await _dbContext.CEFeasibilityExpertOtherDetail.FirstOrDefaultAsync(x => x.ExpertOtherDetailId == request.ExpertOtherDetailId && x.IsDeleted == false); if (_detail != null) { _detail.Name = request.Name; _detail.IsDeleted = false; _detail.ModifiedById = request.CreatedById; _detail.ModifiedDate = DateTime.UtcNow; await _dbContext.SaveChangesAsync(); } response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(DeleteFeasibilityExperrtDetailsCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { CEFeasibilityExpertOtherDetail expertInfo = await _dbContext.CEFeasibilityExpertOtherDetail.FirstOrDefaultAsync(c => c.ExpertOtherDetailId == request.ExpertOtherDetailId && c.IsDeleted == false); expertInfo.IsDeleted = true; expertInfo.ModifiedById = request.ModifiedById; expertInfo.ModifiedDate = DateTime.UtcNow; await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }