예제 #1
0
        public IActionResult EditRequestOff(int id)
        {
            RequestOff requestOff = context.RequestsOff.Single(x => x.ID == id);

            ViewBag.requestOff = requestOff;
            EditRequestOffViewModel model = new EditRequestOffViewModel
            {
                StartTime = requestOff.StartTime,
                EndTime   = requestOff.EndTime,
                Notes     = requestOff.Notes
            };

            return(View(model));
        }
예제 #2
0
        public IActionResult EditRequestOff(int id, EditRequestOffViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            RequestOff requestOff = context.RequestsOff.Single(x => x.ID == id);

            requestOff.StartTime = model.StartTime;
            requestOff.EndTime   = model.EndTime;
            requestOff.Notes     = model.Notes;
            context.SaveChanges();

            return(RedirectToAction("requestoff"));
        }