public ActionResult SchedulerCreate(ScheduleViewModel scheduleViewModel) { try { if (ModelState.IsValid) { if (!_repository.Fetch<Scheduler>().Any(p => p.Name == scheduleViewModel.Name)) { var newScheduler = new Scheduler(); newScheduler.Id = _uniqueId.GetId(); newScheduler.Maker = User.Identity.GetUserName(); newScheduler.OsysDateTime = DateTime.Now; newScheduler.EditDateTime = DateTime.Now; newScheduler.Status = MyEnums.StatusOptions.Added; newScheduler.Active = MyEnums.Active.Disable; newScheduler.IntervalType = scheduleViewModel.IntervalType; newScheduler.Interval = scheduleViewModel.Interval; newScheduler.Name = scheduleViewModel.Name; _repository.SaveNew(newScheduler); _logs.LogAudit(User.Identity.GetUserName(), "SchedulerCreate_HTTPPOST", Request.UserHostName, "Created Scheduler :" + newScheduler.Name, "Created"); } else { ModelState.AddModelError("", scheduleViewModel.Name + " Already Exists!"); return View(scheduleViewModel); } } return RedirectToAction("SchedulerIndex"); } catch (Exception ex) { _logs.LogError(User.Identity.GetUserName(), "SchedulerCreate_HTTPPOST", "Error: " + ex.Message, Request.ServerVariables["REMOTE_ADDR"]); return HttpNotFound(); } }
public ActionResult SchedulerEdit(ScheduleViewModel scheduleViewModel) { try { if (ModelState.IsValid) { var updateSchedule = _repository.Find<Scheduler>(scheduleViewModel.Id); updateSchedule.Maker = User.Identity.GetUserName(); updateSchedule.EditDateTime = DateTime.Now; updateSchedule.Status = MyEnums.StatusOptions.Edited; updateSchedule.Active = MyEnums.Active.Disable; updateSchedule.Interval = scheduleViewModel.Interval; updateSchedule.IntervalType = scheduleViewModel.IntervalType; updateSchedule.Name = scheduleViewModel.Name; _repository.SaveUpdate(updateSchedule); _logs.LogAudit(User.Identity.GetUserName(), "SchedulerEdit_HTTPPOST", Request.UserHostName, "Edited Scheduler :" + updateSchedule.Name, "Edited"); } return RedirectToAction("SchedulerIndex"); } catch (Exception ex) { _logs.LogError(User.Identity.GetUserName(), "SchedulerEdit_HTTPPOST", "Error: " + ex.Message, Request.ServerVariables["REMOTE_ADDR"]); return HttpNotFound(); } }
public ActionResult SchedulerEdit(Guid id) { try { var model = _repository.Find<Scheduler>(id); var returnModel = new ScheduleViewModel { Interval = model.Interval, IntervalType = model.IntervalType, Name = model.Name, Id = model.Id }; return View(returnModel); } catch (Exception ex) { _logs.LogError(User.Identity.GetUserName(), "HoldingEdit_HTTPGET", "Error: " + ex.Message, Request.ServerVariables["REMOTE_ADDR"]); return HttpNotFound(); } }