public SerializedContractor UpdateContractor(SerializedContractor sc, int ctrID) { Contractor ctr = _db.Contractors.Where(c => c.ContractorID == ctrID).FirstOrDefault(); ctr.Name = sc.Name; _db.SaveChanges(); return(GetContractor(ctrID)); }
public SerializedContractor CreateContractor(SerializedContractor sc) { Contractor ctr = _db.Contractors.Create(); ctr.Name = sc.Name; _db.Contractors.Add(ctr); return(GetContractor(ctr.ContractorID)); }
// PUT api/<controller>/5 public SerializedContractor Put(int id, [FromBody] SerializedContractor value) { return(_repo.UpdateContractor(value, id)); }
// POST api/<controller> public SerializedContractor Post([FromBody] SerializedContractor value) { return(_repo.CreateContractor(value)); }
public SerializedContractor GetContractor(int ctrID) { SerializedContractor sc = _db.Contractors.AsQueryable().Where(c => c.ContractorID == ctrID).Select(SerializedContractor.GenerationLambda).FirstOrDefault(); return(sc); }