public async Task<IHttpActionResult> PutStoreservice(int id, StoreService Storeservice) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != Storeservice.StoreServiceNo) { return BadRequest(); } db.Entry(Storeservice).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoreserviceExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostStoreservice(StoreService Storeservice) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.StoreServices.Add(Storeservice); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = Storeservice.StoreServiceNo }, Storeservice); }
private async Task<List<StoreService>> AddStoreService(Store store, string service) { List<StoreService> storeServices = new List<StoreService>(); var arr = HttpUtility.UrlDecode(service.ToString()).Split(','); for (int i = 0; i < arr.Length; i++) { StoreService storeservice = new StoreService(); storeservice.StoreNo = store.StoreNo; storeservice.CodeID = arr[i].ToString().Trim(); storeServices.Add(storeservice); } db.StoreServices.AddRange(storeServices); await db.SaveChangesAsync(); return storeServices; }