public async Task <IHttpActionResult> PutCellTypeMaster(int id, CellTypeMaster cellTypeMaster) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cellTypeMaster.Id) { return(BadRequest()); } db.Entry(cellTypeMaster).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CellTypeMasterExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult CreateCell(CellTypeMaster cellMaster) { var getRm = _capitaContext.CellTypeMasters.ToList(); foreach (var item in getRm) { if (item.CellType.Trim().ToLower() == cellMaster.CellType.Trim().ToLower()) { return(View("CustomerExist")); } } if (cellMaster.Id == 0) { _capitaContext.CellTypeMasters.Add(cellMaster); } else { var vendorIbDB = _capitaContext.CellTypeMasters.Single(v => v.Id == cellMaster.Id); vendorIbDB.CellType = cellMaster.CellType; } _capitaContext.SaveChanges(); return(RedirectToAction("CreateCellType", "MasterCreation")); }
public async Task <IHttpActionResult> GetCellTypeMaster(int id) { CellTypeMaster cellTypeMaster = await db.CellTypeMasters.FindAsync(id); if (cellTypeMaster == null) { return(NotFound()); } return(Ok(cellTypeMaster)); }
public async Task <IHttpActionResult> PostCellTypeMaster(CellTypeMaster cellTypeMaster) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CellTypeMasters.Add(cellTypeMaster); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = cellTypeMaster.Id }, cellTypeMaster)); }
public async Task <IHttpActionResult> DeleteCellTypeMaster(int id) { CellTypeMaster cellTypeMaster = await db.CellTypeMasters.FindAsync(id); if (cellTypeMaster == null) { return(NotFound()); } db.CellTypeMasters.Remove(cellTypeMaster); await db.SaveChangesAsync(); return(Ok(cellTypeMaster)); }