public async Task <ApiResponse> Handle(DeletePriorityOtherDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { PriorityOtherDetail priorityInfo = await _dbContext.PriorityOtherDetail.FirstOrDefaultAsync(c => c.PriorityOtherDetailId == request.PriorityOtherDetailId && c.IsDeleted == false); priorityInfo.IsDeleted = true; priorityInfo.ModifiedById = request.ModifiedById; priorityInfo.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(AddPriorityOtherDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { PriorityOtherDetail _detail = new PriorityOtherDetail { PriorityOtherDetailId = request.PriorityOtherDetailId.Value, Name = request.Name, ProjectId = request.ProjectId, IsDeleted = false, CreatedById = request.CreatedById, CreatedDate = DateTime.UtcNow }; await _dbContext.PriorityOtherDetail.AddAsync(_detail); await _dbContext.SaveChangesAsync(); response.CommonId.LongId = _detail.PriorityOtherDetailId; 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(EditPriorityOtherDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { PriorityOtherDetail _detail = await _dbContext.PriorityOtherDetail.FirstOrDefaultAsync(x => x.PriorityOtherDetailId == request.PriorityOtherDetailId && x.IsDeleted == false); if (_detail != null) { _detail.Name = request.Name; _detail.IsDeleted = false; _detail.ModifiedById = request.ModifiedById; _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); }