public IActionResult CreateExpenditureType(CreateExpenditureTypeDto createExpenditure) { var result = _expenditureService.CreateExpenditureType(createExpenditure); if (!result.IsSuccess) { return(BadRequest(result)); } return(Ok(result.Response)); }
public ServiceResult <CreateExpenditureTypeDto> CreateExpenditureType(CreateExpenditureTypeDto expenditure) { var validation = _fluentValidator.Validate(expenditure); if (!validation.IsValid) { return(_mapper.Map <ServiceResult <CreateExpenditureTypeDto> >(validation.ToServiceResult <CreateExpenditureTypeDto>(null))); } ExpenditureType newExpenditure = new ExpenditureType() { Id = new Guid(), Name = expenditure.Name, CanRepeat = expenditure.CanRepeat, IsImportant = expenditure.IsImportant }; _dataContext.ExpenditureTypes.Add(newExpenditure); _dataContext.SaveChanges(); return(new ServiceResult <CreateExpenditureTypeDto>(expenditure)); }