示例#1
0
        public static ChangeDataInMyProfileViewModel GetAllDataToView(string login)
        {
            ChangeDataInMyProfileViewModel changeDataInMyProfileViewModel = new ChangeDataInMyProfileViewModel();

            changeDataInMyProfileViewModel.changeEmailViewModel        = new ChangeEmailViewModel();
            changeDataInMyProfileViewModel.changePersonalDataViewModel = new ChangePersonalDataViewModel();
            changeDataInMyProfileViewModel.deliveryAddressViewModel    = new DeliveryAddressViewModel();

            using (sklepEntities db = new sklepEntities())
            {
                Users user = db.Users.Where(x => x.UserName == login).Single();
                changeDataInMyProfileViewModel.changePersonalDataViewModel.Name    = user.Name;
                changeDataInMyProfileViewModel.changePersonalDataViewModel.Surname = user.Surname;
                if (user.PhoneNumber != null)
                {
                    changeDataInMyProfileViewModel.changePersonalDataViewModel.PhoneNumber = user.PhoneNumber;
                }
                changeDataInMyProfileViewModel.deliveryAddressViewModel.City       = user.City;
                changeDataInMyProfileViewModel.deliveryAddressViewModel.NumOfHouse = user.NumOfHouse;
                changeDataInMyProfileViewModel.deliveryAddressViewModel.PostCode   = user.PostCode;
                changeDataInMyProfileViewModel.deliveryAddressViewModel.Street     = user.Street;
                changeDataInMyProfileViewModel.changeEmailViewModel.Email          = user.Email;
                return(changeDataInMyProfileViewModel);
            }
        }
示例#2
0
        public ActionResult Scraper()
        {
            List <ScraperViewModel> listShopScrap = new List <ScraperViewModel>();

            using (sklepEntities db = new sklepEntities())
            {
                var shopsScrap = db.Scrapers;
                foreach (Scrapers item in shopsScrap)
                {
                    ScraperViewModel shpScrap = new ScraperViewModel();
                    shpScrap.ProductID  = item.ProductID;
                    shpScrap.XKomPrice  = GetPriceFromScraper(item.XKomPrice, item.XKomLinkChecked);
                    shpScrap.AlsenPrice = GetPriceFromScraper(item.AlsenPrice, item.AlsentLinkChecked);
                    shpScrap.VobisPrice = GetPriceFromScraper(item.VobisPrice, item.VobistLinkChecked);
                    shpScrap.CeneoPrice = GetPriceFromScraper(item.CeneoPrice, item.CeneoLinkChecked);
                    shpScrap.LastUpdate = (DateTime)item.DateLastUpdate;
                    if (item.DifferencePrice != null)
                    {
                        shpScrap.DifferencePrice = ((decimal)item.DifferencePrice).ToString("C2");
                    }
                    listShopScrap.Add(shpScrap);
                }
            }
            return(View(listShopScrap));
        }
示例#3
0
 public static bool isRootCategory(int categoryID)
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Categories.Where(x => x.CategoryID == categoryID && x.ParentCategoryID == categoryID).Any());
     }
 }
示例#4
0
 public static bool IsExistsDelivery(string name)
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Deliveries.Where(x => x.Name == name).Any());
     }
 }
示例#5
0
 public static int GetNumberOfAllOrders()                // uzyskanie liczby wszystkich zamowien z bazy danych
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Orders.Count());
     }
 }
示例#6
0
 public static int GetNumberOfOrdersToRealize()                // uzyskanie liczby zamowien do realizacji z bazy danych
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Orders.Where(x => x.Status != "Zakończono").Count());
     }
 }
示例#7
0
 public static int GetNumberOfClients()                // uzyskanie liczby klientow z bazy danych
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Users.Count());
     }
 }
示例#8
0
 public static List <Categories> GetCategoriesToLayout()
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Categories.ToList());
     }
 }
示例#9
0
        private static string GetShortDescriptionOrder(int orderID)                                  // uzyskanie skroconego opisu zamowienia
        {
            string description = "";

            using (sklepEntities db = new sklepEntities())
            {
                var productsID = db.ProductsOfOrders.Where(x => x.NumOfOrderID == orderID).Select(x => x.ProductID);
                int counter    = 0;
                foreach (int item in productsID)
                {
                    if (counter != 0)
                    {
                        description = description + "/";
                    }
                    string nameProduct = db.Products.Where(x => x.ProductID == item).Select(x => x.Name).Single();
                    description = description + nameProduct;
                    counter++;
                }
            }
            if (description.Length > 30)
            {
                description = string.Concat(description.Take(30)) + "...";
            }
            else
            {
                while (description.Length < 30)
                {
                    description += " ";
                }
            }
            return(description);
        }
示例#10
0
 public static bool CheckActiveAccountAsync(string login)
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Users.Where(u => u.UserName.Equals(login) && u.IsActive == "A").Any());
     }
 }
示例#11
0
 public static int GetNumberOfProducts()                // uzyskanie liczby produktow z bazy danych
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Products.Count());
     }
 }
示例#12
0
 public static bool CheckLoginExists(string login)    // sprawdzenie czy login istnieje w bazie danych
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Users.Where(u => u.UserName.Equals(login)).Any());
     }
 }
示例#13
0
 public static bool CheckEmailExists(string email)    // sprawdzenie czy email istnieje w bazie danych
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Users.Where(u => u.Email.Equals(email)).Any());
     }
 }
示例#14
0
 public static int GetUserID(string login)    // uzyskanie ID uzytkownika
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Users.Where(x => x.UserName == login).Select(x => x.UserID).Single());
     }
 }
示例#15
0
 public static string GetUserLogin(int userID)    // uzyskanie loginu uzytkownika
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Users.Where(x => x.UserID == userID).Select(x => x.UserName).Single());
     }
 }
示例#16
0
 public static string GetUserEmail(string login)    // uzyskanie adresu email uzytkownika
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Users.Where(x => x.UserName == login).Select(x => x.Email).Single());
     }
 }
示例#17
0
        public void countDifferencePrice()
        {
            using (sklepEntities db = new sklepEntities())
            {
                var productsScraped = db.Scrapers;
                foreach (Scrapers item in productsScraped)
                {
                    Products product = db.Products.Where(x => x.ProductID == item.ProductID).SingleOrDefault();

                    decimal priceProduct = (1 + product.Vat) * product.PriceN;

                    List <decimal> listPrices = new List <decimal>();

                    if (isOnePrice(item.XKomPrice, ref listPrices) && isOnePrice(item.VobisPrice, ref listPrices) &&
                        isOnePrice(item.AlsenPrice, ref listPrices) && isOnePrice(item.CeneoPrice, ref listPrices))
                    {
                        decimal minPrice        = listPrices.Min();
                        decimal differencePrice = priceProduct - minPrice;
                        item.DifferencePrice = differencePrice;
                    }
                    else
                    {
                        item.DifferencePrice = null;
                    }
                }

                db.SaveChanges();
            }
        }
示例#18
0
        public ActionResult ScraperSzczegoly(int productID)
        {
            ScraperDetailsViewModel scraperDetails = new ScraperDetailsViewModel();

            using (sklepEntities db = new sklepEntities())
            {
                Scrapers scraper = db.Scrapers.Where(x => x.ProductID == productID).FirstOrDefault();
                if (scraper.DifferencePrice != null)
                {
                    scraperDetails.DifferencePrice = ((decimal)scraper.DifferencePrice).ToString("C2");
                }
                scraperDetails.LastUpdate       = (DateTime)scraper.DateLastUpdate;
                scraperDetails.XKomPrice        = ReplacePriceScraper(scraper.XKomPrice);
                scraperDetails.XKomLinks        = GetLinks(scraper.XKomLink);
                scraperDetails.XKomLinkChecked  = scraper.XKomLinkChecked;
                scraperDetails.VobisPrice       = ReplacePriceScraper(scraper.VobisPrice);
                scraperDetails.VobisLinks       = GetLinks(scraper.VobistLink);
                scraperDetails.VobisLinkChecked = scraper.VobistLinkChecked;
                scraperDetails.AlsenPrice       = ReplacePriceScraper(scraper.AlsenPrice);
                scraperDetails.AlsenLinks       = GetLinks(scraper.AlsentLink);
                scraperDetails.AlsenLinkChecked = scraper.AlsentLinkChecked;
                scraperDetails.CeneoPrice       = ReplacePriceScraper(scraper.CeneoPrice);
                scraperDetails.CeneoLinks       = GetLinks(scraper.CeneoLink);
                scraperDetails.CeneoLinkChecked = scraper.CeneoLinkChecked;
                scraperDetails.ProductID        = productID;
            }
            return(View(scraperDetails));
        }
示例#19
0
 public static bool CheckCategoryExists(int categoryID)    // sprawdzenie czy kategoria istnieje w bazie danych
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Categories.Where(u => u.CategoryID.Equals(categoryID)).Any());
     }
 }
示例#20
0
        public ActionResult PobierzFakture(int orderID)
        {
            using (sklepEntities db = new sklepEntities())
            {
                Orders order = db.Orders.Where(x => x.OrderID == orderID).SingleOrDefault();
                if (order == null)
                {
                    return(RedirectToAction("BiezaceZamowienia"));
                }
                string userNameFromOrder = db.Users.Where(x => x.UserID == order.UserID).Select(x => x.UserName).SingleOrDefault();
                if (User.Identity.Name != userNameFromOrder)
                {
                    return(RedirectToAction("BiezaceZamowienia"));
                }
                string filename    = "FV_" + order.OrderID + "_" + userNameFromOrder;
                string filepath    = AppDomain.CurrentDomain.BaseDirectory + "\\Faktury\\" + filename + ".pdf";
                byte[] filedata    = System.IO.File.ReadAllBytes(filepath);
                string contentType = MimeMapping.GetMimeMapping(filepath);

                var cd = new System.Net.Mime.ContentDisposition
                {
                    FileName = filename,
                    Inline   = true,
                };

                Response.AppendHeader("Content-Disposition", cd.ToString());

                return(File(filedata, contentType));
            }
        }
示例#21
0
 public static bool CheckExistsCommentFromUser(string login, int productID)
 {
     using (sklepEntities db = new sklepEntities())
     {
         return(db.Users.Where(user => user.UserName == login).Join(db.Comments, user => user.UserID, pr => pr.UserID,
                                                                    (user, pr) => new { pr.UserID, user.UserName, pr.ProductID }).Where(pr => pr.ProductID == productID).Any());
     }
 }
示例#22
0
 public ActionResult KlienciSzczegoly(int userID)
 {
     using (sklepEntities db = new sklepEntities())
     {
         Users users = db.Users.Where(x => x.UserID == userID).Single();
         return(View(users));
     }
 }
示例#23
0
 public ActionResult SuccessView(int orderID, string paymentId, string token, string PayerID)
 {
     using (sklepEntities db = new sklepEntities())
     {
         Orders order = db.Orders.Where(x => x.OrderID == orderID).Single();
         order.Status = "Wpłacono";
         db.SaveChanges();
     }
     return(View());
 }
示例#24
0
 public static bool RemoveDelivery(int deliveryID)
 {
     using (sklepEntities db = new sklepEntities())
     {
         Deliveries delivery = db.Deliveries.Where(x => x.DeliveryID == deliveryID).Single();
         db.Deliveries.Remove(delivery);
         db.SaveChanges();
         return(true);
     }
 }
示例#25
0
 public static bool DeleteUserAccount(string login)
 {
     using (sklepEntities db = new sklepEntities())
     {
         Users user = db.Users.Where(u => u.UserName == login).Single();
         user.IsActive = "U";
         db.SaveChanges();
         return(true);
     }
 }
示例#26
0
 public ActionResult KlienciUsun(int userID)
 {
     using (sklepEntities db = new sklepEntities())
     {
         Users user = db.Users.Where(x => x.UserID == userID).Single();
         user.IsActive = "U";
         db.SaveChanges();
         TempData["Message"] = "Konto zostało usunięte";
         return(RedirectToAction("Klienci"));
     }
 }
示例#27
0
        public static List <CategoryView> GetCategoriesNamesForSearchName(int categoryID, string productName)
        {
            List <CategoryView> listCategories = new List <CategoryView>();

            if (categoryID == -1)
            {
                using (sklepEntities db = new sklepEntities())
                {
                    var tempCategories = from pr in db.Products
                                         where pr.Name.Contains(productName)
                                         join cat in db.Categories
                                         on pr.CategoryID equals cat.CategoryID
                                         select new { cat.CategoryID, cat.Name, cat.ParentCategoryID };
                    var categories = tempCategories.GroupBy(p => p.CategoryID).Select(s => s.FirstOrDefault());

                    foreach (var item in categories)
                    {
                        CategoryView tempCategory = new CategoryView();
                        tempCategory.CategoryID       = item.CategoryID;
                        tempCategory.Name             = item.Name;
                        tempCategory.ParentCategoryID = item.ParentCategoryID;
                        listCategories.Add(tempCategory);
                    }
                    return(listCategories);
                }
            }
            else
            {
                using (sklepEntities db = new sklepEntities())
                {
                    Categories category         = db.Categories.Where(x => x.CategoryID == categoryID).Single();
                    int        parentCategoryID = category.ParentCategoryID;
                    var        categories       = db.Categories.Where(x => x.ParentCategoryID == parentCategoryID && x.CategoryID != parentCategoryID);

                    var tempCategories = from pr in db.Products
                                         where pr.Name.Contains(productName)
                                         join cat in categories
                                         on pr.CategoryID equals cat.CategoryID
                                         select new { cat.CategoryID, cat.Name, cat.ParentCategoryID };
                    var tempCategories1 = tempCategories.GroupBy(p => p.CategoryID).Select(s => s.FirstOrDefault());

                    foreach (var item in tempCategories1)
                    {
                        CategoryView tempCategory = new CategoryView();
                        tempCategory.CategoryID       = item.CategoryID;
                        tempCategory.Name             = item.Name;
                        tempCategory.ParentCategoryID = item.ParentCategoryID;
                        listCategories.Add(tempCategory);
                    }
                }

                return(listCategories);
            }
        }
示例#28
0
 public ActionResult StatusyUsun(int statusID)
 {
     using (sklepEntities db = new sklepEntities())
     {
         Statuses status = db.Statuses.Where(x => x.StatusID == statusID).Single();
         db.Statuses.Remove(status);
         db.SaveChanges();
         TempData["Message"] = "Status został usunięty";
         return(RedirectToAction("Statusy"));
     }
 }
示例#29
0
        public static bool VerifyPassword(string login, string passwordView)            // weryfikacja hasla do konta uzytkownika
        {
            bool doesPasswordMatch = false;

            using (sklepEntities db = new sklepEntities())
            {
                string passwordDB = db.Users.Where(x => x.UserName == login).Select(x => x.Password).Single();
                doesPasswordMatch = BCrypt.Net.BCrypt.Verify(passwordView, passwordDB);
            }
            return(doesPasswordMatch);
        }
示例#30
0
 public ActionResult Statusy()
 {
     if (TempData["Message"] != null)
     {
         ModelState.AddModelError("", TempData["Message"].ToString());
     }
     using (sklepEntities db = new sklepEntities())
     {
         return(View(db.Statuses.ToList()));
     }
 }