Exemple #1
0
        public virtual ActionResult Create([DataSourceRequest] DataSourceRequest request, TaskViewModel task)
        {
            if (KiemTraSession() == true)
            {
                return(RedirectToAction("DangNhap", "QuanTri"));
            }
            if (Session["PhongHop"] == null)
            {
                return(RedirectToAction("DangKy", "LichHop"));
            }

            NhanVien nv = (NhanVien)Session["DangNhap"];

            task.CreatedUserId = nv.Id;

            task.CreatedDate = DateTime.Now;
            task.OwnerID     = int.Parse(Session["PhongHop"].ToString());
            task.Status      = true;

            if (ModelState.IsValid && KiemTraLichTrung(task.Start.ToString("d/M/yyyy H:m"), task.End.ToString("d/M/yyyy H:m"), "0", task.RecurrenceRule) == "1")
            {
                taskService.Insert(task, ModelState);
            }

            string  sNoiDung = " <p>Dear Ms. Đoan,</p><p>  <b>" + nv.HoTen + "</b> như sau:</p>";
            LichHop lh       = db.LichHops.SingleOrDefault(n => n.ID == task.TaskID);

            sNoiDung += LayNoiDungLich(lh);
            sNoiDung += "<p>Trân trọng.</p>";
            MailLich(sNoiDung);

            return(Json(new[] { task }.ToDataSourceResult(request, ModelState)));
        }
Exemple #2
0
        public virtual JsonResult Create([DataSourceRequest] DataSourceRequest request, TaskViewModel task)
        {
            if (ModelState.IsValid)
            {
                taskService.Insert(task, ModelState);
            }

            return(Json(new[] { task }.ToDataSourceResult(request, ModelState)));
        }
        public virtual JsonResult Create(TaskViewModel task)
        {
            if (ModelState.IsValid)
            {
                taskService.Insert(task, ModelState);
            }

            return(Json(new[] { task }));
        }
        public IActionResult Post(TaskViewModel task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.Values.SelectMany(v => v.Errors).Select(error => error.ErrorMessage)));
            }

            service.Insert(task, null);

            return(new ObjectResult(new DataSourceResult {
                Data = new[] { task }, Total = 1
            }));
        }