Esempio n. 1
0
        public void BuildLocationShouldSucceed()
        {
            //Arrange
            var locationsModel = new LocationsModel
            {
                Value = new List <LocationLocalModel>
                {
                    new LocationLocalModel {
                        Warehouse = "Warehouse B",
                        Gate      = "DB",
                        Row       = "3",
                        Position  = "001",
                        Site      = "LB1227"
                    }
                }
            };

            //Act
            var service = new LocationBuildService();
            var result  = service.BuildLocation(locationsModel);

            //Assert
            result.Should().NotBeNull();
            result.Should().BeOfType <LocationSiteModel>();
        }
Esempio n. 2
0
        public async Task <IActionResult> Search(string q)
        {
            LocationsModel locationsInfo     = new LocationsModel();
            string         Baseurl           = "https://localhost:44326/";
            var            loactionsResponse = "";
            var            zomatoApiKey      = _config["ZomatoApiKey"];
            var            latitude          = HttpContext.Session.GetString("latitude");
            var            longitude         = HttpContext.Session.GetString("longitude");

            if (latitude != null && longitude != null)
            {
                using (var client = new HttpClient())
                {
                    //Passing service base url
                    client.BaseAddress = new Uri(Baseurl);
                    client.DefaultRequestHeaders.Clear();
                    //Define request data format
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    client.DefaultRequestHeaders.Add("user-key", zomatoApiKey);
                    //Sending request to find web api REST service resource using HttpClient
                    HttpResponseMessage Res = await client.GetAsync("https://developers.zomato.com/api/v2.1/locations?q=" + q + "&lat=" + latitude + "&lon=" + longitude);

                    //Checking the response is successful or not which is sent using HttpClient
                    if (Res.IsSuccessStatusCode)
                    {
                        //Storing the response details recieved from web api
                        loactionsResponse = Res.Content.ReadAsStringAsync().Result;
                        //Deserializing the response recieved from web api and storing into the Model
                        locationsInfo = JsonConvert.DeserializeObject <LocationsModel>(loactionsResponse);
                    }
                }
            }
            return(View(locationsInfo));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("LocationId,LocationName,LocationTitle,LocationDescription,LocationMap,ImageFile,LocationRating")] LocationsModel locationsModel)
        {
            if (id != locationsModel.LocationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(locationsModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocationsModelExists(locationsModel.LocationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(locationsModel));
        }
Esempio n. 4
0
        public NoticeModel(
            VersionConfiguration versionConfig,
            IServiceStateProvider serviceStateProvider,
            LocationsModel locationsModel,
            ServiceModel serviceModel
            )
        {
            this.IsRelevant             = versionConfig.ExistingVersionInstalled;
            this.LocationsModel         = locationsModel;
            this.ServiceModel           = serviceModel;
            this.Header                 = "Notice";
            this.ExistingVersion        = versionConfig.UpgradeFromVersion;
            this.CurrentVersion         = versionConfig.CurrentVersion;
            this.ReadMoreOnUpgrades     = ReactiveCommand.Create();
            this.ReadMoreOnXPackOpening = ReactiveCommand.Create();
            this._serviceStateProvider  = serviceStateProvider;
            this.Refresh();

            if (!string.IsNullOrWhiteSpace(this.CurrentVersion?.Prerelease))
            {
                if (versionConfig.ExistingVersionInstalled)
                {
                    this.UpgradeTextHeader = TextResources.NoticeModel_ToPrerelease_Header;
                    this.UpgradeText       = TextResources.NoticeModel_ToPrerelease;
                }
                else
                {
                    this.UpgradeTextHeader = TextResources.NoticeModel_Prerelease_Header;
                    this.UpgradeText       = TextResources.NoticeModel_Prerelease;
                }
                this.IsRelevant = true;                 //show prerelease notice always
            }
            else if (!string.IsNullOrWhiteSpace(this.ExistingVersion?.Prerelease))
            {
                this.UpgradeTextHeader = TextResources.NoticeModel_FromPrerelease_Header;
                this.UpgradeText       = TextResources.NoticeModel_FromPrerelease;
                this.IsRelevant        = true;          //show prerelease notice always
            }
            else
            {
                var v      = Enum.GetName(typeof(VersionChange), versionConfig.VersionChange);
                var d      = Enum.GetName(typeof(InstallationDirection), versionConfig.InstallationDirection);
                var prefix = nameof(NoticeModel) + "_" + v + d;
                this.UpgradeTextHeader = TextResources.ResourceManager.GetString(prefix + "_Header");
                this.UpgradeText       = TextResources.ResourceManager.GetString(prefix);
            }

            if (!string.IsNullOrWhiteSpace(this.UpgradeTextHeader))
            {
                this.UpgradeTextHeader = string.Format(this.UpgradeTextHeader, versionConfig.UpgradeFromVersion, versionConfig.CurrentVersion);
            }

            this.ShowOpeningXPackBanner       = this.ExistingVersion < XPackModel.XPackInstalledByDefaultVersion;
            this.ShowUpgradeDocumentationLink = versionConfig.VersionChange == VersionChange.Major || versionConfig.VersionChange == VersionChange.Minor;

            this.ExistingVersionInstalled = versionConfig.ExistingVersionInstalled;
        }
        public List <LocationsModel> GetAll()
        {
            //SQL command for selecting all from customers table
            string sqlQuery = "SELECT * FROM Locations";


            //Empty list of customersModel to add and return
            List <LocationsModel> locations = new List <LocationsModel>();

            //Using SqlConnection to establish connection to database
            //using SqlCommand passing in the SqlConnection and the sqlQuery
            using (SqlConnection con = new SqlConnection(_connectionString))

                using (SqlCommand cmd = new SqlCommand(sqlQuery, con))
                {
                    //open the connection
                    con.Open();

                    //SqlDataReader is used because we are reading data from the database
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        //while there are records in the database
                        while (reader.Read())
                        {
                            //store each value into the properties of customersViewModel
                            LocationsModel temp = new LocationsModel()
                            {
                                locationID       = Convert.ToInt64(reader["locationID"]),
                                locationName     = reader["locationName"].ToString(),
                                locationPhone    = Convert.ToInt64(reader["locationPhone"].ToString()),
                                locationCity     = reader["locationCity"].ToString(),
                                locationState    = reader["locationState"].ToString(),
                                locationDistrict = reader["locationDistrict"].ToString()
                            };
                            //Add the customers object to the List of customers

                            locations.Add(temp);



                            Console.WriteLine("       +================================================================+");
                            Console.WriteLine("       +----------------------------------------------------------------+");
                            Console.WriteLine("        LOCATION ID   " + " | " + temp.locationID);
                            Console.WriteLine("        LOCATION NAME " + " | " + temp.locationName);
                            Console.WriteLine("        LOCATION PHONE" + " | " + temp.locationPhone);
                            Console.WriteLine("        LOCATION CITY " + " | " + temp.locationCity);
                            Console.WriteLine("        LOCATION STATE" + " | " + temp.locationState);
                            Console.WriteLine("        LOCATION DISTRICT " + " | " + temp.locationDistrict);
                            Console.WriteLine("       +----------------------------------------------------------------+");
                        }
                    }
                }
            return(locations);
        }
Esempio n. 6
0
 public int Edit(int id, LocationsModel ObjLocationsModel)
 {
     try
     {
         if (id > 0)
         {
             if (ObjLocationsModel != null)
             {
                 Location ObjLocations = DBContext.Locations.Where(a => a.Location_ID == id).FirstOrDefault();
                 if (ObjLocations != null)
                 {
                     //LocationsModel Edit Properties mapping here.
                     //ObjLocations.Profile_Name = ObjLocationsModel.Profile_Name;
                     //ObjLocations.Password = ObjLocationsModel.Password;
                     //ObjLocations.First_Name = ObjLocationsModel.First_Name;
                     //ObjLocations.Middle_Name = ObjLocationsModel.Middle_Name;
                     //ObjLocations.Last_Name = ObjLocationsModel.Last_Name;
                     //ObjLocations.Email_Address = ObjLocationsModel.Email_Address;
                     //ObjLocations.Contact_Number = ObjLocationsModel.Contact_Number;
                     //ObjLocations.Cell_Number = ObjLocationsModel.Cell_Number;
                     //ObjLocations.Location_ID = ObjLocationsModel.Location_ID;
                     //ObjLocations.PickUp_Address = ObjLocationsModel.PickUp_Address;
                     //ObjLocations.Drop_Address = ObjLocationsModel.Drop_Address;
                     //ObjLocations.QR_Code = ObjLocationsModel.QR_Code;
                     //ObjLocations.Rating = ObjLocationsModel.Rating;
                     //ObjLocations.Created_DateTime = ObjLocationsModel.Created_DateTime;
                     //ObjLocations.Created_By = ObjLocationsModel.Created_By;
                     //ObjLocations.Modified_DateTime = ObjLocationsModel.Modified_DateTime;
                     //ObjLocations.Modified_By = ObjLocationsModel.Modified_By;
                     //ObjLocations.Deleted = ObjLocationsModel.Deleted;
                     DBContext.SubmitChanges();
                     return(ObjLocations.Location_ID);
                 }
                 else
                 {
                     return(WebApiResponse.NoRecordFound);
                 }
             }
             else
             {
                 return(WebApiResponse.InputObjectIsNull);
             }
         }
         else
         {
             return(WebApiResponse.InputIdInvalid);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public LocationSiteModel BuildLocation(LocationsModel locationsModel)
        {
            var locations  = locationsModel.Value;
            var warehouses = locations.GroupBy(x => x.Warehouse)
                             .Select(loc => new { Name = loc.Key, Items = loc.ToList() });

            var location = new LocationSiteModel();

            location.Warehouses = new List <WarehouseModel>();

            foreach (var warehouse in warehouses)
            {
                var warehouseLocal = new WarehouseModel();
                warehouseLocal.Name  = warehouse.Name;
                warehouseLocal.Gates = new List <GateModel>();

                var gates = warehouse.Items.GroupBy(x => x.Gate)
                            .Select(g => new { Name = g.Key, Items = g.ToList() });

                foreach (var gate in gates)
                {
                    var gateLocal = new GateModel {
                        Name = gate.Name
                    };
                    gateLocal.Rows = new List <RowModel>();

                    var rows = gate.Items.GroupBy(x => x.Row)
                               .Select(r => new { Name = r.Key, Items = r.ToList() });

                    foreach (var row in rows)
                    {
                        var rowLocal = new RowModel
                        {
                            Name = row.Name
                        };

                        var positions = row.Items.GroupBy(x => x.Position)
                                        .Select(p => new PositionModel {
                            Name = p.Key
                        });

                        rowLocal.Positions = new List <PositionModel>(positions);
                        gateLocal.Rows.Add(rowLocal);
                    }
                    warehouseLocal.Gates.Add(gateLocal);
                }
                location.Warehouses.Add(warehouseLocal);
            }

            return(location);
        }
Esempio n. 8
0
        public NoticeModel(
            VersionConfiguration versionConfig,
            IServiceStateProvider serviceStateProvider,
            LocationsModel locationsModel,
            ServiceModel serviceModel
            )
        {
            this.IsRelevant         = versionConfig.ExistingVersionInstalled;
            this.LocationsModel     = locationsModel;
            this.ServiceModel       = serviceModel;
            this.Header             = "Notice";
            this.ExistingVersion    = versionConfig.ExistingVersion;
            this.CurrentVersion     = versionConfig.CurrentVersion;
            this.ReadMoreOnUpgrades = ReactiveCommand.Create();

            var e = versionConfig.ExistingVersion;
            var c = versionConfig.CurrentVersion;

            if (!string.IsNullOrWhiteSpace(c?.Prerelease))
            {
                this.UpgradeTextHeader = TextResources.NoticeModel_ToPrerelease_Header;
                this.UpgradeText       = TextResources.NoticeModel_ToPrerelease;
                this.IsRelevant        = true;          //show prerelease notice always
            }
            else if (!string.IsNullOrWhiteSpace(e?.Prerelease))
            {
                this.UpgradeTextHeader = TextResources.NoticeModel_FromPrerelease_Header;
                this.UpgradeText       = TextResources.NoticeModel_FromPrerelease;
                this.IsRelevant        = true;          //show prerelease notice always
            }
            else
            {
                var v      = Enum.GetName(typeof(VersionChange), versionConfig.VersionChange);
                var d      = Enum.GetName(typeof(InstallationDirection), versionConfig.InstallationDirection);
                var prefix = nameof(NoticeModel) + "_" + v + d;
                this.UpgradeTextHeader = TextResources.ResourceManager.GetString(prefix + "_Header");
                this.UpgradeText       = TextResources.ResourceManager.GetString(prefix);
            }
            // TODO: We should show the upgrade notice, even for a patch upgrade.
            if (this.IsRelevant &&
                versionConfig.VersionChange == VersionChange.Patch &&
                versionConfig.InstallationDirection == InstallationDirection.Up)
            {
                this.IsRelevant = false;
            }

            this.ExistingVersionInstalled = versionConfig.ExistingVersionInstalled;
            this.InstalledAsService       = serviceStateProvider.SeesService;
            this.Refresh();
        }
Esempio n. 9
0
        public ActionResult Locations(int?tagId, string tag)
        {
            IPublishedContent recommendationRespository = Helper.TypedContentAtRoot().FirstOrDefault()
                                                          .FirstChild(x => x.DocumentTypeAlias == Constants.NodeAlias.RECOMMENDATIONS_REPOSITORY);

            LocationsModel model = new LocationsModel(
                CurrentPage,
                recommendationRespository,
                Site.IsEnglish,
                tagId,
                tag,
                Services.ContentService);

            return(CurrentTemplate(model));
        }
Esempio n. 10
0
 public ActionResult Edit(int id, LocationsModel ObjInputLocationsModel)
 {
     //Customized try catch block by Imran Khan. CodeSnippet
     try
     {
         string JsonString         = string.Empty;
         string ApiURL             = OTS.GlobalSettings.WebAPIURL + this.GetType().Name.Replace("Controller", string.Empty) + "/" + System.Reflection.MethodBase.GetCurrentMethod().Name + "/" + id;
         int    UpdatedLocationsId = 0;
         UpdatedLocationsId = (int)iWebServiceConsumer.ConsumeJsonWebService(ApiURL, ObjInputLocationsModel, UpdatedLocationsId, OTS.GlobalSettings.WebAPITimeout, out JsonString);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         ViewBag.Error = ex.ToString();
         return(View("Error"));
     }
 }
Esempio n. 11
0
        public async Task <LocationsModel> GetLocations()
        {
            var locations      = (await _unitOfWork.LocationRepository.All()).ToList();
            var locationsModel = new LocationsModel
            {
                LocationModels = new List <LocationModel>()
            };

            foreach (var location in locations)
            {
                locationsModel.LocationModels.Add(new LocationModel
                {
                    LocationId   = location.Id,
                    LocationName = location.Name
                });
            }

            return(locationsModel);
        }
Esempio n. 12
0
        public MainViewModel()
        {
            _core          = new CoreLib();
            _windowService = new WindowService();
            //LocationsModel = new LocationsModel(_core);
            LocationsModel = LocationsModel.Load(_core);
            Options        = new Option(_core);
            _ignoreStorage = IgnoreStorage.Load();

            _configuration = TinyIoCContainer.Current.Resolve <IConfigurationModel>();
            _configuration.PropertyChanged += OnConfigurationPropertyChanged;

            UndoRedoEngine undoRedoEngine = new UndoRedoEngine(_configuration);

            _undoRedoEngine = undoRedoEngine;
            _undoRedoEngine.PropertyChanged += OnUndoRedoEnginePropertyChanged;
            TinyIoCContainer.Current.Register <IUndoRedoEngine, UndoRedoEngine>(undoRedoEngine);

            ThumbnailProvider.Instance.PropertyChanged += OnThumbnailProviderPropertyChanged;
        }
Esempio n. 13
0
 public int Delete(int id, LocationsModel ObjInputLocationsModel)
 {
     try
     {
         //Just keep ObjInputLocationsModel as parameter for Deleted Log.
         Location ObjLocations = DBContext.Locations.Where(a => a.Location_ID == id).FirstOrDefault();
         if (ObjLocations != null)
         {
             DBContext.Locations.DeleteOnSubmit(ObjLocations);
             DBContext.SubmitChanges();
             return(ObjLocations.Location_ID);
         }
         else
         {
             return(0);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 14
0
        public async Task <IActionResult> Create([Bind("LocationId,LocationName,LocationTitle,LocationDescription,LocationMap,ImageFile,LocationRating")] LocationsModel locationsModel)
        {
            if (ModelState.IsValid)
            {
                //Save image to wwwroot/image
                string wwwRootPath = iweb.WebRootPath;
                string fileName    = Path.GetFileNameWithoutExtension(locationsModel.ImageFile.FileName);
                string extension   = Path.GetExtension(locationsModel.ImageFile.FileName);
                locationsModel.ImageName = fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                string path = Path.Combine(wwwRootPath + "/Image/", fileName);
                using (var fileStream = new FileStream(path, FileMode.Create))
                {
                    await locationsModel.ImageFile.CopyToAsync(fileStream);
                }
                //Insert record
                _context.Add(locationsModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(locationsModel));
        }
        public async Task <Result> Handle(ListLocationQuery request, CancellationToken cancellationToken)
        {
            Result result;

            try
            {
                int?skip = request.Skip.ToNullableInt();
                int?top  = request.Top.ToNullableInt();

                var locationDomains = await _locationReadRepository.ListAsync(request.Filter, skip, top);

                var locationModels = _mapper.Map <IEnumerable <LocationModel> >(locationDomains);
                var count          = locationModels.Count();
                var locationModel  = new LocationsModel {
                    Value = locationModels, Count = count, NextLink = null
                };

                result = Result.Ok(locationModel);
            }
            catch (FilterODataException)
            {
                result = Result.Fail(new System.Collections.Generic.List <Failure>()
                {
                    new HandlerFault()
                    {
                        Code    = HandlerFaultCode.InvalidQueryFilter.Name,
                        Message = HandlerFailures.InvalidQueryFilter,
                        Target  = "$filter"
                    }
                }
                                     );
            }
            catch
            {
                result = Result.Fail(CustomFailures.ListLocationFailure);
            }
            return(result);
        }
        // GET: /Address/Locations/
        public async Task <IActionResult> Locations([FromBody] Options options)
        {
            IQueryable <Address> query;
            long count;

            if (string.IsNullOrWhiteSpace(options.SearchBy))
            {
                query = await context.Addresses.GetAsync();

                count = await context.Addresses.CountAsync();
            }
            else
            {
                var search = SearchManager.GenerateWhere <Address>(options.SearchBy);
                query = await context.Addresses.GetAsync(search);

                count = await context.Addresses.CountAsync(search);
            }

            if (!string.IsNullOrEmpty(options.SortDirection))
            {
                query = query.OrderByField(options.SortBy, options.SortDirection == "asc");
            }

            query = query.Skip(options.PageIndex * options.PageSize).Take(options.PageSize);

            var model = new LocationsModel(count, query.Select(adr => new AddressTableModel
            {
                Id      = adr.Id,
                Country = adr.Country,
                Region  = adr.Region,
                City    = adr.City,
                Street  = adr.Street,
                Postal  = adr.Postal
            }).ToList());

            return(model.ToJsonResult());
        }
Esempio n. 17
0
		public LocationsFilter(LocationsModel model)
		: base(new TreeModelAdapter( model ),null)
		{
			LocationsModel = model;
		}
Esempio n. 18
0
 private void ApplyLocationsModel(ElasticsearchYamlSettings settings, LocationsModel locations)
 {
     this.Session.SendProgress(1000, "updating elasticsearch.yml with values from locations model");
     settings.LogsPath = locations.LogsDirectory;
     settings.DataPath = locations.DataDirectory;
 }
Esempio n. 19
0
 public PathViewModel(Model.LocationsModel LocationsModel)
 {
     // TODO: Complete member initialization
     this._locationsModel = LocationsModel;
 }
        public LocationsModel GetInventoryByLocationID()
        {
            LocationsModel location  = new LocationsModel();
            ProductsModel  inventory = new ProductsModel();

            Console.WriteLine("       +----------------------------------------------------------------+");
            Console.WriteLine("         Enter your Location ID Number ");
            Console.WriteLine("       +----------------------------------------------------------------+");
            long productID = Convert.ToInt64(Console.ReadLine());

            Console.WriteLine("       +----------------------------------------------------------------+");
            Console.WriteLine("         Enter your Product ID Number ");
            Console.WriteLine("       +----------------------------------------------------------------+");
            long locationID = Convert.ToInt64(Console.ReadLine());

            string sqlQuerys = "Select * from locations where locationID=@ID";

            string sqlQuery = "SELECT * FROM Products INNER JOIN Locations ON Locations.locationID = Products.productLocationID" + "WHERE locationID=@locationID" + "AND productID=@productID";


            //Using SqlConnection to establish connection to database
            //using SqlCommand passing in the SqlConnection and the sqlQuery
            using (SqlConnection con = new SqlConnection(_connectionString))
                using (SqlCommand cmd = new SqlCommand(sqlQuery, con))
                {
                    con.Open();
                    cmd.Parameters.Add("@locationID", SqlDbType.Int).Value = locationID;
                    cmd.Parameters.Add("@productID", SqlDbType.Int).Value  = productID;
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            location.locationID       = Convert.ToInt32(reader["locationID"]);
                            location.locationName     = reader["locationName"].ToString();
                            location.locationPhone    = Convert.ToInt32(reader["locationID"]);
                            location.locationCity     = reader["locationName"].ToString();
                            location.locationState    = reader["locationName"].ToString();;
                            location.locationDistrict = reader["locationDistrict"].ToString();

                            inventory.productID       = Convert.ToInt32(reader["productID"]);
                            inventory.productQuantity = Convert.ToInt32(reader["productQuantity"]);
                        }

                        {
                            Console.WriteLine();
                            Console.WriteLine("       +================================================================+");
                            Console.WriteLine("       +----------------------------------------------------------------+");
                            Console.WriteLine("        LOCATION ID       " + " | " + locationID);
                            Console.WriteLine("        LOCATION NAME     " + " | " + location.locationName);
                            Console.WriteLine("        LOCATION PHONE    " + " | " + location.locationPhone);
                            Console.WriteLine("        LOCATION STATE    " + " | " + location.locationState);
                            Console.WriteLine();
                            Console.WriteLine("        PRODUCT ID        " + " | " + productID);
                            Console.WriteLine("        PRODUCT NAME      " + " | " + inventory.productName);
                            Console.WriteLine("        PRODUCT QUANTITY  " + " | " + inventory.productQuantity);


                            Console.WriteLine("       +----------------------------------------------------------------+");
                            Console.WriteLine();
                        }
                    }
                    return(location);
                }
        }
Esempio n. 21
0
 public void OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     LocationsModel.Save();
     _core.Dispose();
 }
Esempio n. 22
0
        public LocationsModel GetLocations() //TO BE REFACTORED SOON
        {
            var provinceList = new LocationsModel();

            return(provinceList);
        }