public async Task <IHttpActionResult> PutLocation_Status(int id, Location_Status location_Status) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != location_Status.LocationStatusID) { return(BadRequest()); } db.Entry(location_Status).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Location_StatusExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public object addSupplier(Supplier newSupplier) { db.Configuration.ProxyCreationEnabled = false; dynamic toReturn = new ExpandoObject(); dynamic foundSupplier = new ExpandoObject(); try { foundSupplier = searchSupplier(newSupplier.SupName); if (foundSupplier.Message == "Record Not Found") { Supplier newSuppliertoAdd = new Supplier(); newSuppliertoAdd.SupName = newSupplier.SupName; newSuppliertoAdd.SupCell = newSupplier.SupCell; newSuppliertoAdd.SupEmail = newSupplier.SupEmail; newSuppliertoAdd.SupStreet = newSupplier.SupStreet; newSuppliertoAdd.SupStreetNr = newSupplier.SupStreetNr; newSuppliertoAdd.SupSuburb = newSupplier.SupSuburb; newSuppliertoAdd.SupCode = newSupplier.SupCode; db.Suppliers.Add(newSuppliertoAdd); db.SaveChangesAsync(); toReturn.Message = "Supplier Add Successful"; } else { toReturn.Message = "Duplicate Record Found"; } } catch (Exception) { toReturn.Message = "Supplier already exists."; } return(toReturn); }