public ActionResult UpdateLine(string lineno, LineUpdateDtos cud) { Line lineModelFromRepo = _repository.GetLineByNo(lineno); if (lineModelFromRepo == null) { return(NotFound()); } _mapper.Map(cud, lineModelFromRepo); _repository.UpdateLine(lineModelFromRepo); _repository.SaveChanges(); return(NoContent()); }
public ActionResult AddOrEdit(Line line) { try { if (line.LineId == 0) { _lineRepo.SaveLine(line); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { _lineRepo.UpdateLine(line); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(new { success = false, message = "Error in " + (line.LineId == 0 ? "saving" : "updation") + "\n" + e.Message }, JsonRequestBehavior.AllowGet)); } }