public ActionResult UpdateType(LeaveSallaryType TypeInfoForUpdate) { try { var Type = db.LeaveSallaryTypes.Where(s => s.LeaveTypeId == TypeInfoForUpdate.LeaveTypeId); TypeInfoForUpdate.TableStatusID = 1; db.Entry(Type.SingleOrDefault()).CurrentValues.SetValues(TypeInfoForUpdate); db.SaveChanges(); var type = new LeaveSallaryType() { LeaveTypeId = TypeInfoForUpdate.LeaveTypeId, LeaveTypeName = TypeInfoForUpdate.LeaveTypeName, Persent = TypeInfoForUpdate.Persent, }; var JSON = Json(new { UpdateSuccess = true, TypeUpdateInformation = type }, JsonRequestBehavior.AllowGet); JSON.MaxJsonLength = int.MaxValue; return(JSON); } catch { return(Json(new { UpdateSuccess = false, EMPLH = "" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult InsertLeaveType(LeaveSallaryType leaveType) { int LeaveTypeCounts = db.LeaveSallaryTypes.Count(); try { leaveType.TableStatusID = 1; db.LeaveSallaryTypes.Add(leaveType); db.SaveChanges(); LeaveSallaryType TypeInfo = new LeaveSallaryType { LeaveTypeId = leaveType.LeaveTypeId, LeaveTypeName = leaveType.LeaveTypeName, Persent = leaveType.Persent, }; return(Json(new { SuccessInsert = true, TypeInfos = TypeInfo, TypeCount = LeaveTypeCounts }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }