예제 #1
0
 // GET: Scheduling/Form/:id
 public ActionResult Form(int?id)
 {
     Models.ScheduleAddVM model = null;
     if (id != null)
     {
         IDeviceScenarioService deviceScenarioService = DependencyUtils.Resolve <IDeviceScenarioService>();
         IDeviceService         deviceService         = DependencyUtils.Resolve <IDeviceService>();
         IScenarioService       scenarioService       = DependencyUtils.Resolve <IScenarioService>();
         var item = deviceScenarioService.Get(id);
         if (item != null)
         {
             model = new Models.ScheduleAddVM
             {
                 ScenarioID       = item.ScenarioID,
                 DeviceScenarioId = item.DeviceScenationID,
                 DeviceID         = item.DeviceID,
                 isHorizontal     = scenarioService.GetScenarioOrientationById(item.ScenarioID) ?? true,
                 isFixed          = item.TimesToPlay == null,
                 StartTime        = item.StartTime,
                 TimeToPlay       = item.TimesToPlay,
                 EndTime          = item.EndTime,
                 LayoutID         = item.LayoutID,
             };
         }
     }
     return(View(model));
 }
예제 #2
0
        public async System.Threading.Tasks.Task <ActionResult> Update(Models.ScheduleAddVM model)
        {
            IDeviceScenarioService deviceScenarioService = DependencyUtils.Resolve <IDeviceScenarioService>();

            if (ModelState.IsValid && CheckTimeValid(model.DeviceID, model.StartTime, model.EndTime))
            {
                if (model.isFixed)
                {
                    model.TimeToPlay = null;
                }
                else
                {
                    model.EndTime = null;
                }
                var schedule = deviceScenarioService.Get(model.DeviceScenarioId);
                if (schedule != null)
                {
                    schedule.ScenarioID  = model.ScenarioID;
                    schedule.DeviceID    = model.DeviceID;
                    schedule.EndTime     = model.EndTime;
                    schedule.StartTime   = model.StartTime;
                    schedule.TimesToPlay = model.TimeToPlay;
                }
                await deviceScenarioService.UpdateAsync(schedule);

                return(new ContentResult
                {
                    Content = string.Format("<script type='text/javascript'>window.parent.location.href = '{0}';</script>", Url.Action("Index", "Scheduling")),
                    ContentType = "text/html"
                });
            }
            return(View("Form", model));
        }
예제 #3
0
        // GET: Schedule/Delete/:id
        public ActionResult Delete(int id)
        {
            IDeviceScenarioService deviceScenarioService = DependencyUtils.Resolve <IDeviceScenarioService>();
            var schedule = deviceScenarioService.Get(id);

            if (schedule != null)
            {
                deviceScenarioService.Delete(schedule);
            }
            return(this.RedirectToAction("Index"));
        }
 public JsonResult CheckScenarioIdIsUsed(int id)
 {
     try
     {
         IDeviceScenarioService deviceScenarioService = DependencyUtils.Resolve <IDeviceScenarioService>();
         var deviceScenario = deviceScenarioService.Get(a => a.ScenarioID == id).FirstOrDefault();
         return(Json(new
         {
             isUsing = deviceScenario != null,
         }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }