public JsonResult CreateData(string HD, string RD)
        {
            tblholiday tblholiday     = new tblholiday();
            DateTime   Var            = Convert.ToDateTime(HD).Date;
            var        duplicateEntry = db.tblholidays.Where(m => m.IsDeleted == 0 && m.HolidayDate == Var).ToList();

            if (duplicateEntry.Count > 0)
            {
                TempData["Error"] = "Record already exists";
            }
            else
            {
                tblholiday.CreatedBy   = 1;
                tblholiday.CreatedOn   = DateTime.Now;
                tblholiday.IsDeleted   = 0;
                tblholiday.HolidayDate = Convert.ToDateTime(HD).Date;
                tblholiday.Reason      = RD;
                {
                    db.tblholidays.Add(tblholiday);
                    db.SaveChanges();
                }
            }

            return(Json(tblholiday.HolidayId, JsonRequestBehavior.AllowGet));
        }
        public JsonResult DeleteData(int id = 0)
        {
            tblholiday tblholiday = db.tblholidays.Find(id);

            tblholiday.IsDeleted  = 1;
            tblholiday.ModifiedBy = 1;
            tblholiday.ModifiedOn = DateTime.Now;
            {
                db.Entry(tblholiday).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(Json(tblholiday.HolidayId, JsonRequestBehavior.AllowGet));
        }
 public ActionResult Edit(tblholiday tblholiday)
 {
     if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
     {
         return(RedirectToAction("Login", "Login", null));
     }
     ViewBag.Logout             = Session["Username"].ToString().ToUpper();
     ViewBag.roleid             = Session["RoleID"];
     tblholiday.ModifiedBy      = 1;
     tblholiday.ModifiedOn      = DateTime.Now;
     tblholiday.IsDeleted       = 0;
     db.Entry(tblholiday).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public ActionResult Edit(int id = 0)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"].ToString().ToUpper();
            ViewBag.roleid = Session["RoleID"];
            tblholiday tblholiday = db.tblholidays.Find(id);

            ViewBag.EditDate = Convert.ToDateTime(tblholiday.HolidayDate).ToString("dd/MM/yyyy");
            if (tblholiday == null)
            {
                return(HttpNotFound());
            }
            return(View(tblholiday));
        }