Ejemplo n.º 1
0
 public ActionResult Create(DateTime DayOff)
 {
     if (ModelState.IsValid)
     {
         //Nếu chưa có trong DB thì thêm vào
         var model = _context.Daily_ChicCut_WorkingDateModel.Where(p => p.DayOff == DayOff.Date).FirstOrDefault();
         if (model == null)
         {
             var modelAdd = new Daily_ChicCut_WorkingDateModel()
             {
                 DayOff = DayOff.Date
             };
             _context.Entry(modelAdd).State = EntityState.Added;
             _context.SaveChanges();
         }
         return(Json(new
         {
             Result = true
         }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new
     {
         Result = false,
         ErrorMessage = "Loi"
     }, JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 2
0
        public ActionResult Delete(Daily_ChicCut_WorkingDateModel model, DateTime DayOn)
        {
            //Nếu có ngày nghỉ thì xóa
            var deleteDayOff = _context.Daily_ChicCut_WorkingDateModel.Where(p => p.DayOff == DayOn).FirstOrDefault();

            _context.Entry(deleteDayOff).State = EntityState.Deleted;
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }