public int AddFOT(FOT data) { var res = _context.FOT.Add(data); _context.SaveChanges(); return(res.Entity.Id); }
public bool UpdateFOT(int id, FOT data) { var res = _context.FOT.FirstOrDefault(x => x.Id == id); if (res == null) { return(false); } res.salary = data.salary; res.incentivePayments = data.incentivePayments; res.compensationPayments = data.compensationPayments; _context.SaveChanges(); return(true); }
public IActionResult PutFOT(int id, [FromBody] FOT data) { try { var res = _repository.UpdateFOT(id, data); if (!res) { return(Conflict(409)); } return(Ok(res)); } catch (Exception error) { return(BadRequest(error)); } }
public IActionResult PostFOT(FOT data) { try { var res = _repository.AddFOT(data); if (res == -1) { return(Conflict(409)); } return(Ok(res)); } catch (Exception error) { return(BadRequest(error)); } }