public async Task<IHttpActionResult> PutStoreReviewLike(int id, StoreReviewLike reviewLike) { PetterResultType<StoreReviewLike> petterResultType = new PetterResultType<StoreReviewLike>(); List<StoreReviewLike> storeReviewLikes = new List<StoreReviewLike>(); if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != reviewLike.StoreReviewLikeNo) { return BadRequest(); } StoreReviewLike storeReviewLike = await db.StoreReviewLikes.FindAsync(id); if (storeReviewLike == null) { return NotFound(); } storeReviewLike.StateFlag = StateFlags.Use; storeReviewLike.DateModified = DateTime.Now; storeReviewLike.DateDeleted = null; db.Entry(storeReviewLike).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoreReviewLikeExists(id)) { return NotFound(); } else { throw; } } return Ok(petterResultType); }
public async Task<IHttpActionResult> PostStoreReviewLike(StoreReviewLike storeReviewLike) { PetterResultType<StoreReviewLike> petterResultType = new PetterResultType<StoreReviewLike>(); List<StoreReviewLike> storeReviewLikes = new List<StoreReviewLike>(); if (!ModelState.IsValid) { return BadRequest(ModelState); } storeReviewLike.StateFlag = StateFlags.Use; storeReviewLike.DateCreated = DateTime.Now; storeReviewLike.DateModified = DateTime.Now; db.StoreReviewLikes.Add(storeReviewLike); await db.SaveChangesAsync(); storeReviewLikes.Add(storeReviewLike); petterResultType.IsSuccessful = true; petterResultType.JsonDataSet = storeReviewLikes; return Ok(petterResultType); }