public async Task <IActionResult> PutTblAttribute(long id, TblAttribute tblAttribute) { if (id != tblAttribute.Id) { return(BadRequest()); } _context.Entry(tblAttribute).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TblAttributeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ApiResponse> AttributeById(TblAttribute obj) { var AttributeList = await _context.TblAttribute.FindAsync(obj.Id); var ApiResponse = await response.ApiResult("OK", AttributeList, "Record Found"); return(ApiResponse); }
// GET: Attributes/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } TblAttribute tblAttribute = db.TblAttributes.Find(id); if (tblAttribute == null) { return HttpNotFound(); } return View(tblAttribute); }
public ActionResult Create(TblAttribute tblAttribute) { try { if (ModelState.IsValid) { db.TblAttributes.Add(tblAttribute); db.SaveChanges(); TempData["msg"] = "1"; return RedirectToAction("Index"); } TempData["msg"] = "0"; } catch (Exception ex) { TempData["msg"] = "0"; } return View(tblAttribute); }
public ActionResult Edit( TblAttribute tblAttribute) { try { if (ModelState.IsValid) { db.Entry(tblAttribute).State = EntityState.Modified; db.SaveChanges(); TempData["msg"] = "2"; return RedirectToAction("Index"); } TempData["msg"] = "0"; } catch (Exception ex) { TempData["msg"] = "0"; } return View(tblAttribute); }
public async Task <ApiResponse> AddAttribute(TblAttribute tblAttribute) { try { _context.TblAttribute.Add(tblAttribute); await _context.SaveChangesAsync(); var ApiResponse = await GetAllProduct(); return(ApiResponse); } catch (Exception ex) { var ApiResponse = await response.ApiResult("FAILED", ex, "Error Data Insert"); return(ApiResponse); } // return CreatedAtAction("GetTblAttribute", new { id = tblAttribute.Id }, tblAttribute); }
public async Task <ApiResponse> DeleteAttribute(TblAttribute obj) { //var tblCustomerMaster = await _context.TblCustomerMaster.FindAsync(tblCustomer.Id); _context.Entry(obj).Property(x => x.DeleteDate).IsModified = true; try { var response = await _context.SaveChangesAsync(); var ApiResponse = await GetAllProduct(); return(ApiResponse); } catch (DbUpdateConcurrencyException ex) { var ApiResponse = await response.ApiResult("FALIED", ex, "Erro In Update "); return(ApiResponse); } }
public async Task <ApiResponse> UpdateAttribute(TblAttribute obj) { _context.Entry(obj).State = EntityState.Modified; _context.Entry(obj).Property(x => x.RecordDate).IsModified = false; try { await _context.SaveChangesAsync(); var ApiResponse = await GetAllProduct(); return(ApiResponse); } catch (DbUpdateConcurrencyException ex) { var ApiResponse = await response.ApiResult("FALIED", ex, "Erro In Update "); return(ApiResponse); } }
public async Task <ApiResponse> EnableDisableAttribute(TblAttribute obj) { //var tblCustomerMaster = await _context.TblCustomerMaster.FindAsync(tblCustomer.Id); //_context.Entry(obj).Property(x => x.status).IsModified = true; //try //{ // var response = await _context.SaveChangesAsync(); // var ApiResponse = await GetAllProduct(); // return ApiResponse; //} //catch (DbUpdateConcurrencyException ex) //{ // var ApiResponse = await response.ApiResult("FALIED", ex, "Erro In Update "); // return ApiResponse; //} var ApiResponse = await response.ApiResult("FALIED", "", "No OPeration "); return(ApiResponse); }