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); } }
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)); }
public static bool isRootCategory(int categoryID) { using (sklepEntities db = new sklepEntities()) { return(db.Categories.Where(x => x.CategoryID == categoryID && x.ParentCategoryID == categoryID).Any()); } }
public static bool IsExistsDelivery(string name) { using (sklepEntities db = new sklepEntities()) { return(db.Deliveries.Where(x => x.Name == name).Any()); } }
public static int GetNumberOfAllOrders() // uzyskanie liczby wszystkich zamowien z bazy danych { using (sklepEntities db = new sklepEntities()) { return(db.Orders.Count()); } }
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()); } }
public static int GetNumberOfClients() // uzyskanie liczby klientow z bazy danych { using (sklepEntities db = new sklepEntities()) { return(db.Users.Count()); } }
public static List <Categories> GetCategoriesToLayout() { using (sklepEntities db = new sklepEntities()) { return(db.Categories.ToList()); } }
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); }
public static bool CheckActiveAccountAsync(string login) { using (sklepEntities db = new sklepEntities()) { return(db.Users.Where(u => u.UserName.Equals(login) && u.IsActive == "A").Any()); } }
public static int GetNumberOfProducts() // uzyskanie liczby produktow z bazy danych { using (sklepEntities db = new sklepEntities()) { return(db.Products.Count()); } }
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()); } }
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()); } }
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()); } }
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()); } }
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()); } }
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(); } }
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)); }
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()); } }
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)); } }
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()); } }
public ActionResult KlienciSzczegoly(int userID) { using (sklepEntities db = new sklepEntities()) { Users users = db.Users.Where(x => x.UserID == userID).Single(); return(View(users)); } }
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()); }
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); } }
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); } }
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")); } }
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); } }
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")); } }
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); }
public ActionResult Statusy() { if (TempData["Message"] != null) { ModelState.AddModelError("", TempData["Message"].ToString()); } using (sklepEntities db = new sklepEntities()) { return(View(db.Statuses.ToList())); } }