public async Task <IActionResult> AddFlyer([FromBody] MstEFlyers mstEFlyers) { try { if (mstEFlyers != null) { int id = 0; using (EzyFind_DevContext db = new EzyFind_DevContext()) { await db.SaveChangesAsync(); id = mstEFlyers.Efmid; } response.Status = true; // Operation Status Indicator response.Message = "Successful : Flyer added"; // Exception Message response.Result = id; return(Ok(response)); } else { response.Status = false; // Operation Status Indicator response.Message = "Warning : No Flyer provided"; // Exception Message response.Result = null; return(Ok(response)); } } catch { response.Status = false; // Operation Status Indicator response.Message = "Error : Unable to add special"; // Exception Message response.Result = null; return(Ok(response)); } }
public async Task <IActionResult> PutMstEFlyers([FromRoute] int id, [FromBody] MstEFlyers mstEFlyers) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mstEFlyers.Efmid) { return(BadRequest()); } _context.Entry(mstEFlyers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MstEFlyersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostMstEFlyers([FromBody] MstEFlyers mstEFlyers) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.MstEFlyers.Add(mstEFlyers); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMstEFlyers", new { id = mstEFlyers.Efmid }, mstEFlyers)); }
public async Task <IActionResult> UpdateFlyer(int id, [FromBody] MstEFlyers mstEFlyers) { try { if (mstEFlyers != null && id != 0) { var mMstSpecials = await db.MstSpecials.FindAsync(id); using (EzyFind_DevContext db = new EzyFind_DevContext()) { db.MstEFlyers.Update(mstEFlyers); await db.SaveChangesAsync(); id = mstEFlyers.Efmid; } response.Status = true; // Operation Status Indicator response.Message = "Successful: Flyer added"; // Exception Message response.Result = id; return(Ok(response)); } else { response.Status = false; // Operation Status Indicator response.Message = "Warning : No Flyer provided"; // Exception Message response.Result = null; return(Ok(response)); } } catch { response.Status = false; // Operation Status Indicator response.Message = "Error : Unable to update flyer"; // Exception Message response.Result = null; return(Ok(response)); } }