// GET: Location public ActionResult Index() { var locationSet = locationRepo.ResultTable.ToList(); var model = new LocationIndexViewModel(locationSet); return(View(model)); }
public ActionResult Index(int ID, string Search = "all") { try { string search; if (Search == "") { search = "all"; } else { search = Search; } var model = new LocationIndexViewModel() { ID = ID, Search = search }; return(View(model)); } catch (Exception ex) { if (ex.InnerException == null) { ViewBag.Message = "Function: LocationController.Index_GET\n\nError: " + ex.Message; } else { ViewBag.Message = "Function: LocationController.Index_GET\n\nError: " + (ex.Message + "\n\nInnerException: " + ex.InnerException.Message); }; Session["ErrorMessage"] = ViewBag.Message; return(RedirectToAction("InternalServerError", "Error")); }; }
public ActionResult Index(LocationIndexViewModel model = null) { if (model == null) { model = new LocationIndexViewModel(); } model.Locations = string.IsNullOrWhiteSpace(model.Search) ? _locationRepository.GetAll() : _locationRepository.FindLocations(model.Search); model.Locations = model.Locations.OrderBy(m => m.Name).ToList(); if (model.SortBy == 0) { model.Locations = model.Direction == 0 ? model.Locations.OrderBy(l => l.Name).ToList() : model.Locations.OrderByDescending(l => l.Name).ToList(); } else if (model.SortBy == 1) { model.Locations = model.Direction == 0 ? model.Locations.OrderBy(l => l.Net, new IpAddressComparer()).ThenBy(l => l.Cidr).ToList() : model.Locations.OrderByDescending(l => l.Net_v6, new IpAddressComparer()).ThenByDescending(l => l.Cidr).ToList(); } else if (model.SortBy == 2) { model.Locations = model.Direction == 0 ? model.Locations.OrderBy(l => l.Net_v6, new IpAddressComparer()).ThenBy(l => l.Cidr_v6).ToList() : model.Locations.OrderByDescending(l => l.Net_v6, new IpAddressComparer()).ThenByDescending(l => l.Cidr_v6).ToList(); } return(View(model)); }
public ActionResult Index() { var vm = new LocationIndexViewModel { Locations = _locationService.GetLocations() }; return(View(vm)); }
// // GET: /Location/ public ActionResult Index() { // Get the data var model = new LocationIndexViewModel(); model.Locations = this.locationRepository.GetLocations().ToList(); return(this.View(model)); }
public async Task <ActionResult> SearchResult(LocationIndexViewModel data) { if (data.queries == null) { return(View("Index", data)); } else { var postTask = await client.PostAsJsonAsync("/api/Location/Search", data); var division = await postTask.Content.ReadAsAsync <LocationSearchViewModel>(); return(Json(division, JsonRequestBehavior.AllowGet)); } }
public ActionResult Index(string Message, string Fail) { var data = new LocationIndexViewModel(); data.FailMessage = Fail; data.SuccessMessage = Message; var locations = LocationBLO.Current.GetAllLocation(); for (int i = 0; i < locations.Count; i++) { if (locations[i].Fullname != null) { locations[i].Fullname = "(" + locations[i].Fullname + ")"; } } var list = locations.Where(x => x.RackStatus == Constants.StatusCode.RACK_AVAILABLE); var listavailablerack = list.OrderBy(x => x.RackName).GroupBy(x => x.RackName).Select(x => x.FirstOrDefault()); data.RackAvailableCount = listavailablerack.Count(); var listrack = locations.OrderBy(x => x.RackName).GroupBy(x => x.RackName).Select(x => x.FirstOrDefault()); data.Racks = listrack.Select(x => new SelectListItem { Value = x.RackName, Text = x.RackName + " " + x.Fullname }).ToList(); var listpow = new List <SelectListItem>(); int[] listp = new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; foreach (var i in listp) { string num = (i).ToString(); SelectListItem item = new SelectListItem() { Value = num, Text = num + "KW" }; listpow.Add(item); } data.ListPower = listpow; data.Locations = locations; return(View(data)); }
public JsonResult AddLocation(LocationIndexViewModel data) { var result = new JsonResultModel(); var rack = new Rack(); var existing = RackBLO.Current.GetByName(new Rack { RackName = data.RackName }); if (existing == null) { rack.RackName = data.RackName; rack.MaximumPower = data.MaximumPower; RackBLO.Current.AddRackAndLocation(rack); result.Success = true; } else { result.Success = false; } return(Json(result)); }
public ActionResult Index(LocationIndexViewModel livm) { //if (IsAuthorized()) //{ var existing = RackBLO.Current.GetByName(new Rack { RackName = livm.RackName }); if (existing == null) { var rack = new Rack(); rack.RackName = livm.RackName; rack.MaximumPower = livm.MaximumPower; RackBLO.Current.AddRackAndLocation(rack); return(RedirectToAction("Index", new { Message = "New Rack was added!" })); } else { return(RedirectToAction("Index", new { Fail = "Rack has just been added!" })); } }
public async Task <ActionResult> Edit(string comp_id, string loc_id) { if (loc_id != null && comp_id != null) { LocationUpdateViewModel model = new LocationUpdateViewModel(); var postTask = await client.GetAsync("/api/Location/View/?comp_id=" + comp_id + "&loc_id=" + loc_id); model = await postTask.Content.ReadAsAsync <LocationUpdateViewModel>(); if (model != null) { return(View("Edit", model)); } else { LocationIndexViewModel data = new LocationIndexViewModel(); ViewBag.Error = "No Location Found !"; return(View("Index", data)); } } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
public ActionResult AssignLocation(LocationIndexViewModel livm) { var existing = RequestDAO.Current.Query(x => x.RequestCode == livm.RequestCode).FirstOrDefault(); if (livm.RequestType != "Change" && existing.StatusCode != Constants.StatusCode.REQUEST_PROCESSING) { return(RedirectToAction("Detail", "ProcessRequest", new { code = livm.RequestCode })); } var selectedLocationCodes = livm.Selected .Where(x => x.IsSelected) .Select(x => x.LocationCode) .ToList(); if (selectedLocationCodes.Count == 0) { return(View(livm)); } var location = LocationBLO.Current.GetByKeys(new Location { LocationCode = selectedLocationCodes[0] }); if (location == null) { return(View(livm)); } var locations = LocationBLO.Current.GetAllLocation(new GetLocationQuery { RackCode = location.RackCode }); var startIndex = -1; var endIndex = -1; for (var i = 0; i < locations.Count; i++) { var l = locations[i]; if (startIndex == -1 && selectedLocationCodes.Contains(l.LocationCode)) { startIndex = i; } if (startIndex != -1 && selectedLocationCodes.Contains(l.LocationCode)) { endIndex = i; } if (startIndex != -1 && !selectedLocationCodes.Contains(l.LocationCode)) { break; } } if ((endIndex - startIndex + 1) != livm.Size || (locations[startIndex].ServerCode != null && locations[startIndex].ServerCode != livm.ServerCode) || (locations[endIndex].ServerCode != null && locations[endIndex].ServerCode != livm.ServerCode)) { return(RedirectToAction("AssignLocation", "Location", new { FailMessage = "Assign Location Fail! Try Again!", rType = livm.RequestType, rCode = livm.RequestCode, ServerCode = livm.ServerCode, Size = livm.Size })); } string user = GetCurrentUserName(); bool result = LocationBLO.Current.UpdateLocation(livm.ServerCode, selectedLocationCodes, user, livm.RequestType); if (result) { if (livm.RequestType == "Change") { return(RedirectToAction("Detail", "Server", new { code = livm.ServerCode, Message = "Location was changed!" })); } else { return(RedirectToAction("Detail", "ProcessRequest", new { code = livm.RequestCode })); } } else { if (livm.RequestType == "Change") { return(RedirectToAction("Detail", "Server", new { code = livm.ServerCode })); } else { return(RedirectToAction("Detail", "ProcessRequest", new { code = livm.RequestCode })); } } }
public ActionResult AssignLocation(string ServerCode, string rType, string rCode, int Size, string FailMessage) { var data = new LocationIndexViewModel(); data.Size = Size; data.FailMessage = FailMessage; var server = ServerBLO.Current.GetServerByCode(ServerCode, Constants.StatusCode.SERVER_WAITING); if (rType == "Change") { server = ServerBLO.Current.GetServerByCode(ServerCode, Constants.StatusCode.SERVER_RUNNING); } var locationserver = LocationBLO.Current.GetLocationOfServer(ServerCode); //truong hop assign lan dau if (locationserver.Count == 0) { var locations = LocationBLO.Current.GetNewLocation(server); var listrack = locations.OrderBy(x => x.RackName).GroupBy(x => x.RackName).Select(x => x.FirstOrDefault()); data.Racks = listrack.Select(x => new SelectListItem { Value = x.RackCode, Text = x.RackName }).ToList(); if (RackOfCustomerDAO.Current.GetRackOfCustomer(server).Count > 0) { var locations1 = LocationBLO.Current.GetNewLocation1(server); var listrack1 = locations1.OrderBy(x => x.RackName).GroupBy(x => x.RackName).Select(x => x.FirstOrDefault()); data.Racks1 = listrack1.Select(x => new SelectListItem { Value = x.RackCode, Text = x.RackName }).ToList(); if (data.Racks1.Count > 0) { data.Notice = "HaveRack"; } } } else { var locations = LocationBLO.Current.GetChangeLocation(server); var listrack = locations.OrderBy(x => x.RackName).GroupBy(x => x.RackName).Select(x => x.FirstOrDefault()); data.Racks = listrack.Select(x => new SelectListItem { Value = x.RackCode, Text = x.RackName }).ToList(); if (RackOfCustomerDAO.Current.GetRackOfCustomer(server).Count > 0) { var locations1 = LocationBLO.Current.GetChangeLocation1(server); var listrack1 = locations1.OrderBy(x => x.RackName).GroupBy(x => x.RackName).Select(x => x.FirstOrDefault()); data.Racks1 = listrack1.Select(x => new SelectListItem { Value = x.RackCode, Text = x.RackName }).ToList(); data.Notice = "HaveRack"; } } data.RequestCode = rCode; data.RequestType = rType; data.ServerCode = ServerCode; return(View(data)); }