void Awake()
		{
			model = gameObject.GetComponent<LocationViewModel>();
			previousSearches = new LinkedList<string>();
			if (null == model)
			{
				throw new MissingComponentException();
			}
		}
        public ActionResult Create([DataSourceRequest]DataSourceRequest request, LocationViewModel model)
        {
            var createdModel = base.Create<Location>(model);
            if (createdModel != null)
            {
                model.Id = createdModel.Id;
            }

            return this.GridOperation(model, request);
        }
        public ActionResult Delete(int id, LocationViewModel viewModel)
        {
            try
            {
                _locationService.Delete(id);

                return RedirectToAction("Index");
            }
            catch
            {
                return View(viewModel);
            }
        }
        // GET: /Locations/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var dbModel = _unitOfWork.LocationsRepository.GetItemById(id);

            if (dbModel == null)
            {
                return(HttpNotFound());
            }

            LocationViewModel viewModel = Mapper.Map <Location, LocationViewModel>(dbModel);

            return(View(viewModel));
        }
示例#5
0
        private void CallToRefreshCommandTest1()
        {
            var serviceMock = new Mock <ILocationService>();

            serviceMock.Setup(x => x.GetLocations()).Returns(async() =>
            {
                await Task.Delay(2000);
                return(new VpnLocations());
            });

            var pingerFactoryMock = new Mock <IExecutePingFactory>();

            var viewModel = new LocationViewModel(serviceMock.Object, pingerFactoryMock.Object);

            Assert.False(viewModel.DataRequestInprogress);
            viewModel.RefreshCommand.Execute(null);
            Assert.True(viewModel.DataRequestInprogress);
        }
        public ActionResult Edit(int id, LocationViewModel model)
        {
            var locations = System.Web.HttpContext.Current.Session["locations"] as List <LocationViewModel>;

            if (locations == null)
            {
                return(RedirectToAction("Index"));
            }
            var location = locations.FirstOrDefault(l => l.Id == id);

            if (location == null)
            {
                return(View());
            }

            location.Title = model.Title;
            return(RedirectToAction("Index"));
        }
示例#7
0
        public static bool Create(LocationViewModel locationViewModel)
        {
            using (var _dbContext = new serti_dbContext())
            {
                var location = new Location()
                {
                    Shelf      = locationViewModel.Shelf,
                    Room       = locationViewModel.Room,
                    Bookseller = locationViewModel.Bookseller,
                    Position   = locationViewModel.Position,
                    CreatedAt  = DateTime.Now,
                    UpdatedAt  = DateTime.Now
                };

                _dbContext.Location.Add(location);
                return(_dbContext.SaveChanges() > 0);
            }
        }
        public async Task GET_ReturnsValidLocationViewModel_OnValidBridgeResponse()
        {
            var providerMock = new Mock <IGeocodingProvider>(MockBehavior.Strict);

            providerMock.Setup(provider => provider.ReverseGeocoding(It.IsAny <IPoint>()))
            .ReturnsAsync("location");
            var loggerStub = new Mock <ILogger <GeocodingController> >(MockBehavior.Loose);
            var controller = new GeocodingController(providerMock.Object, loggerStub.Object);

            var result = await controller.Get(0, 0);

            JsonResult jsonResult = (JsonResult)result;

            Assert.IsType <LocationViewModel>(jsonResult.Value);
            LocationViewModel viewModel = (LocationViewModel)jsonResult.Value;

            Assert.Equal("location", viewModel.Location);
        }
示例#9
0
        public ActionResult Create([DataSourceRequest] DataSourceRequest request, LocationViewModel model)
        {
            if (this.locationService.ContainsName(model.Name))
            {
                this.ModelState.AddModelError("Name", $"Database already contains Location with name {model.Name}");
            }

            if (this.ModelState.IsValid && model != null)
            {
                int id = this.locationService.Create(model.Name, int.Parse(model.CompanyId)).Id;
                model = this.locationService
                    .GetById(id)
                    .To<LocationViewModel>()
                    .FirstOrDefault();
            }

            return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState));
        }
        public ActionResult Create(LocationViewModel viewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                    return View(viewModel);

                var location = Mapper.Map<LocationViewModel, Location>(viewModel);

                _locationService.Add(location);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
示例#11
0
        public async Task <ServiceResponseBase> Update(LocationViewModel vm, AccountViewModel account)
        {
            try
            {
                var isExist = await _context.Location.AnyAsync(o => o.LocalBarCode == vm.LocalBarCode &&
                                                               o.CompanyId == account.CompanyId && o.Id != vm.Id);

                if (isExist)
                {
                    return(new ServiceResponseBase()
                    {
                        Status = Status.error, Message = "存在重复条码"
                    });
                }
                var location = await _context.Location.FirstOrDefaultAsync(o => o.Id == vm.Id);

                Mapper.Map(vm, location);
                location.Rack                  = "";
                location.Length                = 0;
                location.Width                 = 0;
                location.Height                = 0;
                location.X                     = 0;
                location.Y                     = 0;
                location.Z                     = 0;
                location.UnitNum               = "";
                location.UnitName              = "";
                location.StorageNum            = location.BranchId.ToString();
                _context.Entry(location).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(new ServiceResponseBase()
                {
                    Status = Status.ok
                });
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, ex);
                return(new ServiceResponseBase()
                {
                    Status = Status.error, Message = ex.Message
                });
            }
        }
示例#12
0
        public ActionResult Details(int id, bool c)
        {
            if (c == false)
            {
                HttpContext.Response.Cookies.Append("Customer", "false");
            }
            ;

            if (id != 0)
            {
                HttpContext.Response.Cookies.Append("LocationID", $"{id}");
            }
            else
            {
                id = int.Parse(HttpContext.Request.Cookies["LocationID"]);
            }

            Location location  = _locationRepo.GetLocationByID(id);
            var      viewModel = new LocationViewModel
            {
                LocationID          = location.LocationID,
                Name                = location.Name,
                Address             = location.Address,
                InventoryViewModels = _inventoryRepo.GetInventoryById(id).Select(m => new InventoryViewModel
                {
                    LocationId = m.LocationId,
                    ProductId  = m.ProductId,
                    Name       = m.Name,
                    Price      = m.Price,
                    Amount     = m.Amount
                }),
                OrderHistoryViewModels = _orderhistoryRepo.GetOrderHistoryByLocationId(id).Select(y => new OrderHistoryViewModel
                {
                    LocationId = y.LocationId,
                    OrderId    = y.OrderId,
                    CustomerId = y.CustomerId,
                    Date       = y.Date,
                    Time       = y.Time
                })
            };


            return(View(viewModel));
        }
示例#13
0
        public LocationViewModel GetLocationByCode(string code)
        {
            LocationViewModel result = new LocationViewModel();
            var location             = _location.GetLocationByCode(code);
            var statuscdname         = _pref.GetLookupByStatusCode(location.StatusCD);
            var locationtypename     = _pref.GetLookupByLocationTypeCode(location.LocationTypeCD);

            result.ID                 = location.ID;
            result.Code               = location.Code;
            result.Description        = location.Description;
            result.No                 = location.No;
            result.Name               = location.Name;
            result.Floor              = location.Floor;
            result.LocationTypeCD     = location.LocationTypeCD;
            result.StatusCD           = location.StatusCD;
            result.StatusCDName       = statuscdname.Value;
            result.LocationTypeCDName = locationtypename.Value;
            return(result);
        }
示例#14
0
        public void GivenNavigatorShowEditView()
        {
            INavigationRepository repository = GenerateRepository();
            LocationController    target     = new LocationController(repository);
            Navigator             navigator  = GenerateNavigator();
            ActionResult          actual;

            actual = target.Edit(navigator);
            Assert.IsNotNull(actual);
            Assert.IsInstanceOfType(actual, typeof(ViewResult));
            ViewResult result = actual as ViewResult;

            Assert.AreEqual("Edit", result.ViewName);
            LocationViewModel model = result.Model as LocationViewModel;

            Assert.AreEqual(model.LocationId, navigator.LocationId);
            Assert.AreEqual(model.LocationName, navigator.LocationName);
            TestViewResult(navigator, result);
        }
        private static void WorkOutOpenUntil(LocationViewModel model, DateTime ukNow, OpeningTimes opening)
        {
            var today = (ukNow.DayOfWeek.ToString().Substring(0, 2).ToUpperInvariant() == opening.Day.Substring(0, 2).ToUpperInvariant());

            var now   = ukNow.TimeOfDay;
            var open1 = (opening.OpensAtTime.HasValue && opening.ClosesAtTime.HasValue && now >= opening.OpensAtTime.Value.TimeOfDay && now <= opening.ClosesAtTime.Value.TimeOfDay);
            var open2 = (opening.OpensAgainAtTime.HasValue && opening.ClosesAgainAtTime.HasValue && now >= opening.OpensAgainAtTime.Value.TimeOfDay && now <= opening.ClosesAgainAtTime.Value.TimeOfDay);
            var open  = today && opening.Scheduled && (open1 || open2);


            if (open && open1)
            {
                model.OpenUntil = opening.ClosesAtTime;
            }
            if (open && open2)
            {
                model.OpenUntil = opening.ClosesAgainAtTime;
            }
        }
示例#16
0
        public ActionResult Update(LocationViewModel location)
        {
            HttpClient httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri("https://localhost:44345/api/");

            var putTask = httpClient.PutAsJsonAsync <LocationViewModel>("locations", location);

            putTask.Wait();

            var putResult = putTask.Result;

            if (putResult.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }

            return(View(location));
        }
示例#17
0
        public EventViewModel(Models.Event campaignEvent)
        {
            Id = campaignEvent.Id;
            if (campaignEvent.Campaign != null)
            {
                CampaignId   = campaignEvent.Campaign.Id;
                CampaignName = campaignEvent.Campaign.Name;
                TimeZoneId   = campaignEvent.Campaign.TimeZoneId;
                if (campaignEvent.Campaign.ManagingOrganization != null)
                {
                    OrganizationId   = campaignEvent.Campaign.ManagingOrganization.Id;
                    OrganizationName = campaignEvent.Campaign.ManagingOrganization.Name;
                    HasPrivacyPolicy = !string.IsNullOrEmpty(campaignEvent.Campaign.ManagingOrganization.PrivacyPolicy);
                }
            }

            Title         = campaignEvent.Name;
            Description   = campaignEvent.Description;
            EventType     = campaignEvent.EventType;
            StartDateTime = campaignEvent.StartDateTime;
            EndDateTime   = campaignEvent.EndDateTime;

            if (campaignEvent.Location != null)
            {
                Location = new LocationViewModel(campaignEvent.Location);
            }

            IsClosed = EndDateTime.UtcDateTime < DateTimeOffset.UtcNow;

            ImageUrl = campaignEvent.ImageUrl;

            //TODO Location
            Tasks = campaignEvent.Tasks != null
                 ? new List <TaskViewModel>(campaignEvent.Tasks.Select(data => new TaskViewModel(data)).OrderBy(task => task.StartDateTime))
                 : new List <TaskViewModel>();

            SignupModel = new EventSignupViewModel();

            RequiredSkills    = campaignEvent.RequiredSkills?.Select(acsk => new SkillViewModel(acsk.Skill)).ToList();
            IsLimitVolunteers = campaignEvent.IsLimitVolunteers;
            IsAllowWaitList   = campaignEvent.IsAllowWaitList;
            Headline          = campaignEvent.Headline;
        }
示例#18
0
        /// <summary>
        /// Converts from Location entity to LocationViewModel
        /// </summary>
        /// <param name="location"></param>
        /// <returns>LocationViewModel</returns>
        public static LocationViewModel Convert(Location location)
        {
            if (location == null)
            {
                return(null);
            }

            var locationViewModel = new LocationViewModel();

            locationViewModel.Latitude   = location.Latitude;
            locationViewModel.Longitude  = location.Longitude;
            locationViewModel.LocationId = location.LocationId;
            locationViewModel.Vehicle    = location.Vehicle != null?VehicleConverter.Convert(location.Vehicle) : null;

            locationViewModel.VehicleId = location.VehicleId;
            locationViewModel.CreatedAt = location.CreatedAt;

            return(locationViewModel);
        }
示例#19
0
        public async Task <IActionResult> GetLocationById(int locationId)
        {
            try
            {
                var      _serviceEndPoint = new ServicesEndPoint(_unitOfWork, _emailService);
                Location res = await _serviceEndPoint.GetLocationById(locationId);

                LocationViewModel results = _Mapper.Map <LocationViewModel>(res);
                if (results == null)
                {
                    return(NotFound(results));
                }
                return(Ok(results));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
示例#20
0
        public async Task <IActionResult> DeleteLocation([FromBody] LocationViewModel locationViewModel)
        {
            try
            {
                var  _serviceEndPoint = new ServicesEndPoint(_unitOfWork, _emailService);
                var  location         = _Mapper.Map <Location>(locationViewModel);
                bool result           = await _serviceEndPoint.DeleteLocation(location);

                if (!result)
                {
                    return(NotFound(locationViewModel));
                }
                return(Ok(new { message = "Succesfully Deleted!", result = result }));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
示例#21
0
        public ActionResult Edit(LocationViewModel model)
        {
            if (ModelState.IsValid)
            {
                var entity = Mapper.Map <Location>(model);

                entity = _locationsRepository.Update(entity);

                _timelineService.RegisterActivity(Realm.BG, ActivityType.LocationUpdated, User.Id);

                Feedback.AddMessageSuccess(LocationResources.LocationEditSuccessMessage);

                return(RedirectToAction(nameof(Index), nameof(LocationsController).RemoveControllerSuffix()));
            }

            model = BuilModel(model);

            return(View("Manager", model));
        }
        private Entities.Location CreateLocationAsync(LocationViewModel model)
        {
            var created = new Entities.Location
            {
                AreaCode    = model.AreaCode,
                City        = model.City,
                Country     = model.Country,
                Description = model.Description,
                Id          = (locations.Count + 1).ToString(),
                Line1       = model.Line1,
                Line2       = model.Line2,
                Name        = model.Name,
                Region      = model.Region
            };

            locations.Add(created);

            return(created);
        }
示例#23
0
        public ActionResult Index(Find.Cms.Models.Pages.LocationItemPage currentPage)
        {
            var model = new LocationViewModel(currentPage);

            if (!ContentReference.IsNullOrEmpty(currentPage.Image))
            {
                model.Image = _contentRepository.Get <ImageData>(currentPage.Image);
            }

            model.LocationNavigation.ContinentLocations = SearchClient.Instance
                                                          .Search <Find.Cms.Models.Pages.LocationItemPage>()
                                                          .Filter(x => x.Continent.Match(currentPage.Continent))
                                                          .PublishedInCurrentLanguage()
                                                          .OrderBy(x => x.PageName)
                                                          .FilterForVisitor()
                                                          .Take(100)
                                                          .StaticallyCacheFor(new System.TimeSpan(0, 10, 0))
                                                          .GetContentResult();

            model.LocationNavigation.CloseBy = SearchClient.Instance
                                               .Search <Find.Cms.Models.Pages.LocationItemPage>()
                                               .Filter(x => x.Continent.Match(currentPage.Continent)
                                                       & !x.PageLink.Match(currentPage.PageLink))
                                               .PublishedInCurrentLanguage()
                                               .FilterForVisitor()
                                               .OrderBy(x => x.Coordinates)
                                               .DistanceFrom(currentPage.Coordinates)
                                               .Take(5)
                                               .StaticallyCacheFor(new System.TimeSpan(0, 10, 0))
                                               .GetContentResult();

            if (currentPage.Categories != null)
            {
                model.Tags = currentPage.Categories.Select(x => _contentRepository.Get <StandardCategory>(x));
            }

            var editingHints = ViewData.GetEditHints <LocationViewModel, Find.Cms.Models.Pages.LocationItemPage>();

            editingHints.AddFullRefreshFor(p => p.Image);
            editingHints.AddFullRefreshFor(p => p.Categories);

            return(View(model));
        }
示例#24
0
 public IEnumerable <LocationData> SearchLocation([FromBody] LocationViewModel model)
 {
     if (ModelState.IsValid)
     {
         using (MyDbEntities db = new MyDbEntities())
         {
             var x = db.LocationDatas.Where(a => a.Latitude > model.MinLatitude && a.Latitude <model.MaxLatitude && a.Longitude> model.MinLongitude && a.Longitude < model.MaxLongitude).ToList();
             if (x.Count() != 0)
             {
                 return(x);
             }
             return(null);
         }
     }
     else
     {
         return(null);
     }
 }
示例#25
0
        public ActionResult AddLocation(LocationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            try
            {
                var location = new Location();
                if (model.Id == 0)
                {
                    location.StreetAddress = model.StreetAddress;
                    location.City          = model.City;
                    location.ZipCode       = model.ZipCode;
                    location.Country       = model.Country;
                    _locationApiCall.PostApiCall(location);


                    TempData["SuccessResultF"] = true;
                    TempData["SuccessResultM"] = "Location added successfully";
                }
                else
                {
                    location = _locationApiCall.GetT(model.Id);
                    location.StreetAddress = model.StreetAddress;
                    location.City          = model.City;
                    location.ZipCode       = model.ZipCode;
                    _locationApiCall.PutApiCall(location, model.Id);


                    TempData["SuccessResultF"] = true;
                    TempData["SuccessResultM"] = "Location edited successfully";
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                TempData["SuccessResultF"] = false;
                TempData["SuccessResultM"] = "Something went wrong.";
                throw ex;
            }
        }
示例#26
0
        public IEnumerable <LocationViewModel> GetLocations()
        {
            var result = _context.Locations
                         .Include(x => x.LocationFacilities)
                         .ThenInclude(x => x.FacilityInstance)
                         .Where(x => x.Deleted == false && x.LocationFacilities.Any(y => y.Deleted == false && y.FacilityInstance.Deleted == false))
                         .OrderBy(x => x.Name)
                         .ToList();

            List <LocationViewModel> value = new List <LocationViewModel>();

            foreach (var location in result)
            {
                LocationViewModel localValue = new LocationViewModel();
                localValue.Address      = location.Address;
                localValue.City         = location.City;
                localValue.Created      = location.Created;
                localValue.Id           = location.ID;
                localValue.Latitude     = location.Latitude;
                localValue.Longitude    = location.Longitude;
                localValue.Modified     = location.Modified;
                localValue.Name         = location.Name;
                localValue.OpeningHours = location.OpeningHours;
                localValue.Phonenumber  = location.Phonenumber;
                localValue.Postcode     = location.Postcode;
                localValue.Facilities   = new List <FacilityViewModel>();

                foreach (var facilityInstance in location.LocationFacilities)
                {
                    FacilityViewModel localFacility = new FacilityViewModel();
                    localFacility.Created  = facilityInstance.Created;
                    localFacility.Id       = facilityInstance.ID;
                    localFacility.Modified = facilityInstance.Modified;
                    localFacility.Name     = facilityInstance.FacilityInstance.Name;
                    localFacility.Value    = facilityInstance.Value;

                    localValue.Facilities.Add(localFacility);
                }

                value.Add(localValue);
            }
            return(value);
        }
示例#27
0
 public ActionResult Edit(int id, LocationViewModel viewModel)
 {
     if (!ModelState.IsValid)
     {
         _logger.LogWarning($"Encountered error editing location, returning to edit page at {DateTime.Now}");
         return(View(viewModel));
     }
     try {
         var location = _repository.GetLocationById(id);
         _repository.UpdateLocation(location); // Not implemented in repository
         _repository.Save();
         _logger.LogInformation($"Edited details of location [{id}] at {DateTime.Now}");
         return(RedirectToAction(nameof(Index)));
     } catch {
         ModelState.AddModelError("", "Unable to update location details");
         _logger.LogWarning($"Encountered error editing location, returning to edit page at {DateTime.Now}");
         return(View(viewModel));
     }
 }
        public IActionResult AddLocation(LocationViewModel model)
        {
            var farm = _farm.AddLocation(model, GetCurrentUserAsync().Result.UserName).Result;

            if (farm.Succeeded)
            {
                _toastNotification.AddSuccessToastMessage(farm.OkMessage, new ToastrOptions
                {
                    PositionClass = ToastPositions.TopCenter
                });
                return(RedirectToAction(nameof(ListLocation)));
            }

            _toastNotification.AddWarningToastMessage(farm.Errors, new ToastrOptions
            {
                PositionClass = ToastPositions.TopCenter
            });
            return(View(nameof(AddLocation), model));
        }
示例#29
0
        public void Save(LocationViewModel locationViewModel)
        {
            using (var _context = new NasscomEntities())
            {
                Location location = (from locations in _context.Location where locations.Id == locationViewModel.Id select locations).FirstOrDefault();
                if (location != null)
                {
                    location.Id          = locationViewModel.Id;
                    location.Description = locationViewModel.Description;
                    location.Name        = locationViewModel.Name;
                }
                else
                {
                    _context.Location.Add(GetEntity(locationViewModel));
                }

                _context.SaveChanges();
            }
        }
        public HttpResponseMessage GetAlltrackingGroupBy(string location, string family)
        {
            try
            {
                //Se obtienen todos los devices por familia
                var devices = dbContext.Devices.Where(d => d.Family.Equals(family));

                //Se obtiene todos los trackings de los devices seleccionados
                var trackings = (from A in dbContext.Trackings
                                 join B in devices on A.DeviceIdDevice equals B.IdDevice
                                 select A).ToList();

                //Se agrupa los trackings por locations
                List <LocationViewModel> locations = new List <LocationViewModel>();

                LocationViewModel      locationVM = new LocationViewModel();
                List <DeviceViewModel> devicesVM  = new List <DeviceViewModel>();

                foreach (var device in trackings.Where(t => t.Location.Equals(location)).GroupBy(t => t.Device))
                {
                    devicesVM.Add(new DeviceViewModel
                    {
                        DeviceName = device.Key.Name,
                        Trackings  = trackings.Where(t => t.Location.Equals(location) && t.DeviceIdDevice.Equals(device.Key.IdDevice)).OrderBy(t => t.Dtm).Select(t => new TrackingResumenViewModel
                        {
                            Dtm         = t.Dtm,
                            Temperature = t.Temperature
                        }).ToList()
                    });
                }

                locationVM.LocationName = location;
                locationVM.Devices.AddRange(devicesVM);
                locations.Add(locationVM);

                return(Request.CreateResponse(HttpStatusCode.OK, locations));
            }
            catch (Exception e)
            {
                var errors = ExceptionHandlerLogger.LogInnerMessages(e);
                return(Request.CreateResponse(HttpStatusCode.Conflict, errors));
            }
        }
示例#31
0
        public async Task <PartialViewResult> UpsertLocationModal(long?id, long?provinceId)
        {
            LocationViewModel model = new LocationViewModel(new LocationDto());

            if (id.HasValue)
            {
                var dto = await _locationAppService.GetLocation(id.Value);

                model = new LocationViewModel(dto);
            }
            else
            {
                if (provinceId.HasValue)
                {
                    model.ProvinceId = provinceId.Value;
                }
            }
            return(PartialView("_UpsertLocationModal", model));
        }
示例#32
0
        public bool UpdateLocation(LocationViewModel LCNViewModel)
        {
            using (CFMMCDEntities db = new CFMMCDEntities())
            {
                LOCATION lcnRow = new LOCATION();

                lcnRow.Id     = int.Parse(LCNViewModel.Id);
                lcnRow.LOCATN = LCNViewModel.LOCATN;
                try
                {
                    if (db.LOCATIONs.Where(o => o.Id.ToString().Equals(LCNViewModel.Id)).Any())
                    {
                        var rowToRemove = db.LOCATIONs.Single(o => o.Id.ToString().Equals(LCNViewModel.Id));
                        db.LOCATIONs.Remove(rowToRemove);
                        db.LOCATIONs.Add(lcnRow);
                    }
                    else
                    {
                        db.LOCATIONs.Add(lcnRow);
                    }
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e.Source);
                    System.Diagnostics.Debug.WriteLine(e.Message);
                    System.Diagnostics.Debug.WriteLine(e.StackTrace);
                    System.Diagnostics.Debug.WriteLine(e.InnerException);
                    Exception f = e.InnerException;
                    while (f != null)
                    {
                        System.Diagnostics.Debug.WriteLine("INNER:");
                        System.Diagnostics.Debug.WriteLine(f.Message);
                        System.Diagnostics.Debug.WriteLine(f.Source);
                        f = f.InnerException;
                    }
                    System.Diagnostics.Debug.WriteLine(e.Data);
                    return(false);
                }
            }
        }
示例#33
0
 public ActionResult Edit(LocationViewModel viewModel)
 {
     try
     {
         var validateName = _locationService.GetNameLocationDuplicate(viewModel.ID, viewModel.Name.Trim());
         var validateCode = _locationService.GetCodeLocationDuplicate(viewModel.ID, viewModel.LocationCode.Trim());
         if (validateName != null)
         {
             ModelState.AddModelError("Name", "Name already exists");
         }
         if (validateCode != null)
         {
             ModelState.AddModelError("LocationCode", "Code already exists");
         }
         var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
         if (!ModelState.IsValid)
         {
             var campusModel = _campusService.GetAll();
             ViewBag.campusViewModel = Mapper.Map <IEnumerable <Campus>, IEnumerable <CampusViewModel> >(campusModel);
             // xy ly loi
             return(View(viewModel));
         }
         else
         {
             // TODO: Add update logic here
             var location = _locationService.GetById(viewModel.ID, new string[] { "Campus" });
             location.CampusID     = viewModel.CampusID;
             location.LocationCode = viewModel.LocationCode.Trim();
             location.Name         = viewModel.Name.Trim();
             location.Description  = viewModel.Description;
             location.Active       = viewModel.Active;
             _locationService.Update(location);
             _locationService.SaveChanges();
             SetAlert("Update Location success", "success");
         }
     }
     catch (Exception e)
     {
         SetAlert("Update Location error", "error");
     }
     return(RedirectToAction("Index"));
 }
示例#34
0
        public IActionResult LocationOrderHistory(int id)
        {
            ViewBag.locations = _locationRepo.GetAll();
            var location = _locationRepo.GetById(id);
            LocationViewModel viewModel = new LocationViewModel
            {
                LocationId = location.Id,
                Name       = location.Name,
            };
            var orderHistory = _orderRepo.GetOrderHistoryofLocation(location);

            viewModel.OrderHistory = orderHistory.Select(o => new OrdersViewModel
            {
                OrderId    = o.OrderId,
                OrderDate  = (DateTime)o.OrderTime,
                Location   = o.StoreLocation.Name,
                OrderTotal = o.totalCost
            }).ToList();
            return(View(viewModel));
        }
示例#35
0
        public ActionResult Create(LocationViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                _logger.LogWarning($"Encountered error creating new location, returning to creation page at {DateTime.Now}");
                return(View(viewModel));
            }
            try {
                var location = new Location(viewModel.Name, viewModel.Address, viewModel.City, viewModel.State, viewModel.Country, viewModel.Zip, viewModel.Phone);

                _repository.AddLocation(location);
                _repository.Save();
                _logger.LogInformation($"Created new location, {location.Name}, at {DateTime.Now}");
                return(RedirectToAction(nameof(Index)));
            } catch {
                ModelState.AddModelError("", "Error creating new location.");
                _logger.LogWarning($"Encountered error creating new location, returning to creation page at {DateTime.Now}");
                return(View(viewModel));
            }
        }
示例#36
0
 public static LocationViewModel ToViewModel(this Location location)
 {
     var value = new LocationViewModel
     {
         Address1 = location.Address1,
         Address2 = location.Address2,
         City = location.City,
         PostalCode = location.PostalCode,
         State = location.State
     };
     return value;
 }
 public void Sorting()
 {
     this.SelectedLocation = null;
 }
示例#38
0
 public void RemoveFileToBeConverted(LocationViewModel location)
 {
     FilesToBeConverted.Remove(location);
 }
 public ActionResult Update([DataSourceRequest]DataSourceRequest request, LocationViewModel model)
 {
     var updatedModel = base.Update(model, model.Id);
     return this.GridOperation(updatedModel, request);
 }
        public ActionResult Destroy([DataSourceRequest]DataSourceRequest request, LocationViewModel model)
        {
            this.Delete<Location>(model);

            return this.GridOperation(model, request);
        }
示例#41
0
 public LocationViewModel WhereAreWe(LocationViewModel whereAreWe)
 {
     return whereAreWe;
 }
示例#42
0
 public void AddFileToBeConverted(LocationViewModel location)
 {
     FilesToBeConverted.Add(location);
 }
示例#43
0
        public ActionResult Destroy([DataSourceRequest]DataSourceRequest request, LocationViewModel model)
        {
            this.locationService.Delete(model.Id);

            return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState));
        }