Beispiel #1
0
        public string UpdatePriceFilterField()
        {
            string result = "No products to update";

            var products = _db.ProductRepository.GetAll().Where(p => p.PriceFilter == null).Take(1000).ToList();

            if (products != null)
            {
                var uProducts = products.ToList();

                if (uProducts != null && uProducts.Count > 0)
                {
                    foreach (var p in uProducts)
                    {
                        if (p.Price.HasValue)
                        {
                            try
                            {
                                p.PriceFilter = Convert.ToDouble(p.Price.Value);

                                _db.ProductRepository.Update(p);
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }

                    _db.SaveChanges();
                }



                result = "Success: " + products.Count().ToString();
            }


            return(result);
        }
Beispiel #2
0
        public ActionResult CreatePlace(PlaceViewModel model)
        {
            if (ModelState.IsValid)
            {
                var newPlace = new Place();

                newPlace.Name        = model.Name;
                newPlace.NameSV      = model.NameSV;
                newPlace.PlaceTypeId = model.PlaceTypeId;
                newPlace.ParentId    = model.ParentId;

                _context.PlaceRepository.Insert(newPlace);

                _context.SaveChanges();

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }
Beispiel #3
0
        public ActionResult CreateProduct(ProductViewModel model)
        {
            if (ModelState.IsValid)
            {
                var newProduct = new Product();
                newProduct.ProductTypeId      = 1;
                newProduct.SalesResponsibleId = model.SalesResponsibleId;
                newProduct.PlaceId            = model.PlaceId;
                newProduct.Description        = model.Description;
                newProduct.ExternalLink       = model.ExternalLink;
                newProduct.Address            = model.Address;
                newProduct.Lat              = model.Lat;
                newProduct.Long             = model.Long;
                newProduct.IsApproved       = model.IsApproved;
                newProduct.InsertDate       = DateTime.Now;
                newProduct.LivingSpace      = model.LivingSpace;
                newProduct.NumberOfRooms    = model.NumberOfRooms;
                newProduct.Price            = model.Price;
                newProduct.MonthlyCharge    = model.MonthlyCharge;
                newProduct.SquareMeterPrice = model.SquareMeterPrice;
                newProduct.YearBuilt        = model.YearBuilt;
                newProduct.ExternalPicLink  = model.ExternalPicLink;
                newProduct.PlotSize         = model.PlotSize;
                newProduct.RefNr            = model.RefNr;

                _context.ProductRepository.Insert(newProduct);

                Console.Write(newProduct.Id);

                _context.SaveChanges();

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }
Beispiel #4
0
        private void SaveProduct(ProductItem product)
        {
            var item = new Product();

            item.ProductTypeId      = product.ProductTypeId;
            item.SalesResponsibleId = product.SalesResponsibleId;
            item.PlaceId            = product.PlaceId;
            item.Description        = product.Description;
            item.LivingSpace        = product.LivingSpace;
            item.NumberOfRooms      = product.NumberOfRooms;
            item.Price        = product.Price;
            item.ExternalLink = product.ExternalLink;
            item.InsertDate   = DateTime.Now;
            item.Address      = product.Address;
            item.Lat          = product.Lat;
            item.Long         = product.Long;
            item.IsApproved   = true;
            item.RefNr        = product.RefNr;
            item.YearBuilt    = product.YearBuilt;

            _db.ProductRepository.Insert(item);
            _db.SaveChanges();

            item.ThumbnailUrl = UploadImages(item.Id, product);
            _db.ProductRepository.Update(item);
            _db.SaveChanges();
        }