//ToanTXSE //Get screen List by location ID public static List <Models.ScreenVM> GetScreenIdByBrandId() { IScreenService screenService = DependencyUtils.Resolve <IScreenService>(); ILocationService locationService = DependencyUtils.Resolve <ILocationService>(); var ScreenVM = new List <Models.ScreenVM>(); var user = Helper.GetCurrentUser(); var screenList = screenService.GetScreenIdByBrandId(user.BrandID); foreach (var item in screenList) { var location = locationService.Get(item.LocationID); var locationString = location.Address + ", Quận " + location.District + ", TP." + location.Province; var m = new Models.ScreenVM { Name = item.ScreenName, Description = item.Description, ScreenId = item.ScreenID, isHorizontal = item.isHorizontal, LocationId = item.LocationID, Location = locationString, }; ScreenVM.Add(m); } return(ScreenVM); }
public async System.Threading.Tasks.Task <ActionResult> Add(Models.ScreenVM model) { if (ModelState.IsValid) { var screen = new Data.Models.Entities.Screen { ScreenName = model.Name, Description = model.Description, LocationID = model.LocationId, isHorizontal = model.isHorizontal, }; await this.screenService.CreateAsync(screen); Session.Clear(); Session["ADD_RESULT"] = true; return(new ContentResult { Content = string.Format("<script type='text/javascript'>window.parent.location.href = '{0}';</script>", Url.Action("Index", "Screen")), ContentType = "text/html" }); } return(Json(new { success = false, }, JsonRequestBehavior.AllowGet)); }
// GET: Screen/Form/:id public ActionResult Form(int?id) { Models.ScreenVM model = null; if (id != null) { var screen = this.screenService.Get(id); if (screen != null) { model = new Models.ScreenVM { Name = screen.ScreenName, ScreenId = screen.ScreenID, //truyen screen Id qua view de phan biet update hay addnew Description = screen.Description, LocationId = screen.LocationID, isHorizontal = screen.isHorizontal, }; } } ViewBag.locationList = LocationController.GetLocationIdByBrandId(); ViewBag.resolutionList = ResolutionController.GetResolutionListByBrandID(); return(View(model)); }
public async System.Threading.Tasks.Task <ActionResult> Update(Models.ScreenVM model) { if (ModelState.IsValid) { var screen = this.screenService.Get(model.ScreenId); if (screen != null) { screen.ScreenName = model.Name; screen.Description = model.Description; screen.LocationID = model.LocationId; } await this.screenService.UpdateAsync(screen); Session.Clear(); Session["UPDATE_RESULT"] = true; return(new ContentResult { Content = string.Format("<script type='text/javascript'>window.parent.location.href = '{0}';</script>", Url.Action("Index", "Screen")), ContentType = "text/html" }); } return(View("Form", model)); }
public JsonResult ReceiveLocationId(string id) { int locationId = Int32.Parse(id); try { //get box list by location ID IBoxService boxService = DependencyUtils.Resolve <IBoxService>(); IDeviceService deviceService = DependencyUtils.Resolve <IDeviceService>(); IMapper mapper = DependencyUtils.Resolve <IMapper>(); var boxs = boxService.Get().ToList(); var boxVMs = new List <Models.AndroidBoxVM>(); foreach (var item in boxs) { //check boxID is being matched if (deviceService.Get(a => a.BoxID == item.BoxID).FirstOrDefault() == null) { if (item.LocationID == locationId) { var b = new Models.AndroidBoxVM { Name = item.BoxName, Description = item.Description, BoxId = item.BoxID, LocationId = item.LocationID, }; boxVMs.Add(b); } } } IScreenService screenService = DependencyUtils.Resolve <IScreenService>(); var screens = screenService.Get().ToList(); var screenVMs = new List <Models.ScreenVM>(); foreach (var item in screens) { //check boxID is being matched if (deviceService.Get(a => a.ScreenID == item.ScreenID).FirstOrDefault() == null) { if (item.LocationID == locationId) { var b = new Models.ScreenVM { Name = item.ScreenName, Description = item.Description, ScreenId = item.ScreenID, LocationId = item.LocationID, isHorizontal = item.isHorizontal, }; screenVMs.Add(b); } } } return(Json(new { boxListByLocationId = boxVMs, screenListByLocationId = screenVMs }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }