public IHttpActionResult PutClientShiftAssignment(int id, ClientShiftAssignment clientShiftAssignment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != clientShiftAssignment.ClientId) { return(BadRequest()); } db.Entry(clientShiftAssignment).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ClientShiftAssignmentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutWorkShift(string id, WorkShift workShift) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != workShift.Shift) { return(BadRequest()); } db.Entry(workShift).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!WorkShiftExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutSvcCode(string id, SvcCode svcCode) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != svcCode.SvcCodeValue) { return(BadRequest()); } db.Entry(svcCode).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SvcCodeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public HttpResponseMessage Put(int id, Provider provider) { //quick check to determine if the provider is a valid provider? if (id != provider.ProviderId) { throw new HttpResponseException(HttpStatusCode.NotFound); } ProviderResponse response = null; using (var db = new ClientsProvidersDbEntities()) { response = Mapper.Map <Provider, ProviderResponse>(provider); db.Providers.Add(provider); try { db.SaveChanges(); } catch (Exception ex) { var myError = ex.Message; } return(Request.CreateResponse(HttpStatusCode.OK, response)); } }
public HttpResponseMessage Post(Provider provider) { ProviderResponse[] response = null; using (var db = new ClientsProvidersDbEntities()) { var providerRecord = new Provider(); providerRecord.FirstName = provider.FirstName; providerRecord.LastName = provider.LastName; providerRecord.Active = provider.Active; try { StringContent content = new StringContent(JsonConvert.SerializeObject(provider), Encoding.UTF8, "application/json"); db.SaveChanges(); } catch (Exception ex) { string errors = "Could not save provider"; } response = Mapper.Map <Provider, ProviderResponse[]>(provider); return(Request.CreateResponse(HttpStatusCode.OK, response)); } }