public async Task <InformCostType> AddInformCostType(InformCostType costType) { var result = await _context.InformCostTypes.AddAsync(costType); await _context.SaveChangesAsync(); return(result.Entity); }
public async Task <InformCostType> UpdateInformCostType(InformCostType costType) { var result = await _context.InformCostTypes.FirstOrDefaultAsync(s => s.Id == costType.Id); if (result != null) { result.CostType = costType.CostType; await _context.SaveChangesAsync(); return(result); } return(null); }
public async Task <ActionResult <InformCostType> > CreateInformCostType(InformCostType informCostType) { try { if (informCostType == null) { return(BadRequest()); } var createdInformCostType = await _informCostTypeRepository.AddInformCostType(informCostType); return(createdInformCostType); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from the database.")); } }
public async Task UpdateInformCostType(int id, InformCostType type) { await httpClient.PutAsJsonAsync($"/api/informCostType/{id}", type); }
public async Task <InformCostType> CreateInformCostType(InformCostType type) { var result = await httpClient.PostAsJsonAsync("/api/informCostTypes", type); return(await result.Content.ReadAsAsync <InformCostType>()); }
public async Task <ActionResult <InformCostType> > UpdateInformCostType(int id, InformCostType informCostType) { try { if (id != informCostType.Id) { return(BadRequest()); } var informCostTypeToUpdate = await _informCostTypeRepository.GetInformCostType(id); if (informCostTypeToUpdate == null) { return(NotFound($"InformCostType with id = {id} not found")); } return(await _informCostTypeRepository.UpdateInformCostType(informCostType)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from the database.")); } }