public ActionResult Save(Session objses) { lsession = new List <Session>(); if (ModelState.IsValid == true) { if (objses.SessionId == 0) { objses.SessionId = Convert.ToInt32(db.Sessions.Max(x => (int?)x.SessionId) ?? 0) + 1; objses.UpdateBy = Session["User"].ToString(); objses.UpdateDate = DateTime.Now.Date; db.Sessions.Add(objses); } else { Session _session = db.Sessions.Where(p => p.SessionId == objses.SessionId).FirstOrDefault(); if (_session != null) { db.Entry(_session).CurrentValues.SetValues(objses); } } db.SaveChanges(); ModelState.Clear(); } return(View("index")); }
public ActionResult Save(FeeGroup obj) { //if (ModelState.IsValid == true) //{ if (obj.FGroupId == 0) { obj.FGroupId = Convert.ToInt32(db.FeeGroups.Max(x => (int?)x.FGroupId) ?? 0) + 1; obj.SessionName = "2013-2014"; obj.UpdateDate = DateTime.Now.Date; obj.UpdateBy = Session["User"].ToString(); db.FeeGroups.Add(obj); } else { FeeGroup _feegroup = db.FeeGroups.Where(x => x.FGroupId == obj.FGroupId).FirstOrDefault(); if (_feegroup != null) { db.Entry(_feegroup).CurrentValues.SetValues(obj); } } db.SaveChanges(); ModelState.Clear(); //} return(View("Index")); }
public ActionResult Save(CAST obj) { if (ModelState.IsValid == true) { if (obj.CastId == 0) { obj.CastId = Convert.ToInt32(db.CASTs.Max(x => (int?)x.CastId) ?? 0) + 1; obj.Sessionname = "2013-2014"; db.CASTs.Add(obj); } else { CAST _cast = db.CASTs.Where(x => x.CastId == obj.CastId).FirstOrDefault(); if (_cast != null) { // _cast.CastName = obj.CastName; db.Entry(_cast).CurrentValues.SetValues(obj); } } db.SaveChanges(); ModelState.Clear(); } return(View("Index")); }
public ActionResult Save(CoursesType obj) { // if (ModelState.IsValid == true) //{ if (obj.ID == 0) { obj.ID = Convert.ToInt32(db.CoursesTypes.Max(m => (int?)m.ID) ?? 0) + 1; obj.Sessionname = "2013-2014"; obj.UpdateBy = Session["User"].ToString(); obj.UpdateDate = DateTime.Now.Date; db.CoursesTypes.Add(obj); } else { CoursesType _courses = db.CoursesTypes.Where(x => x.ID == obj.ID).FirstOrDefault(); if (_courses != null) { // _cast.CastName = obj.CastName; db.Entry(_courses).CurrentValues.SetValues(obj); } } db.SaveChanges(); ModelState.Clear(); // } return(View("CourceT")); }
public ActionResult Save(Class obj) { if (obj.ClassId == 0) { obj.ClassId = Convert.ToInt32(db.Classes.Max(m => (int?)m.ClassId) ?? 0) + 1; obj.sessionName = "2013-2014"; obj.UpdateBy = Session["User"].ToString(); obj.UpdateDate = DateTime.Now.Date; db.Classes.Add(obj); } else { Class _class = db.Classes.Where(x => x.ClassId == obj.ClassId).FirstOrDefault(); if (_class != null) { db.Entry(_class).CurrentValues.SetValues(obj); } } db.SaveChanges(); ModelState.Clear(); return(View("Class")); }
public ActionResult Save(ExtraCertificate obj) { if (obj.CertificateId == 0) { obj.CertificateId = Convert.ToInt32(db.ExtraCertificates.Max(m => (int?)m.CertificateId) ?? 0) + 1; obj.SessionName = "2013-2014"; obj.UpdateBy = Session["User"].ToString(); obj.UpdateDate = DateTime.Now.Date; db.ExtraCertificates.Add(obj); } else { ExtraCertificate _feedetail = db.ExtraCertificates.Where(x => x.CertificateId == obj.CertificateId).FirstOrDefault(); if (_feedetail != null) { db.Entry(_feedetail).CurrentValues.SetValues(obj); } } db.SaveChanges(); ModelState.Clear(); return(View("Index")); }