Exemple #1
0
        public string UpdateProduct(int id, Product product)
        {
            try
            {
                Sell_BuyEntities db = new Sell_BuyEntities();
                Product          p  = db.Products.Find(id);
                p.name          = product.name;
                p.delivery_date = product.delivery_date;
                p.price         = product.price;
                p.quantity      = product.quantity;
                p.id_brand      = product.id_brand;
                p.currency      = product.currency;
                p.C_description = product.C_description;
                p.producer      = product.producer;

                p.C_image     = product.C_image;
                p.rating      = product.rating;
                p.id_magazine = product.id_magazine;
                p.C_status    = product.C_status;


                db.SaveChanges();
                return(p.name + "was succefully updated");
            }
            catch (Exception e)
            {
                return("Error:" + e.Message);
            }
        }
 public string UpdateUser(int id, User user)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         User             u  = db.Users.Find(id);
         u.name_first  = user.name_first;
         u.name_last   = user.name_last;
         u.name_middle = user.name_middle;
         u.phone       = user.phone;
         u.mail        = user.mail;
         u.id_country  = user.id_country;
         u.id_region   = user.id_region;
         u.id_sity     = user.id_sity;
         //u.C_status = user.C_status;
         //u.active = user.active;
         u.id_language = user.id_language;
         u.C_image     = user.C_image;
         //u.date_register = user.date_register;
         u.C_login    = user.C_login;
         u.C_password = user.C_password;
         db.SaveChanges();
         return("Информация изменена");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
        public string UpdateLoginProfile(int _iduser, string newlogin)
        {
            string strResult = "";

            try
            {
                Sell_BuyEntities db = new Sell_BuyEntities();
                var result          = db.Users.SingleOrDefault(u => u.id == _iduser);
                if (result != null)
                {
                    var user = db.Users.FirstOrDefault(x => x.C_login == newlogin);
                    if (user != null)
                    {
                        strResult = "Пользователь стаким логином уже существует \n";
                    }
                    else
                    {
                        result.C_login = newlogin;
                        db.SaveChanges();
                        strResult = "Логин успешно изменен на " + newlogin;
                    }
                }
            }
            catch (Exception e)
            {
                strResult = "Error !";
                nLog.WriteLog("DB_Entity_DAL -> DB_Operation -> DB_User -> UpdateLoginProfile :\r\n Message: " + e.Message + "\r\n " + e.StackTrace + "", 0);
            }
            return(strResult);
        }
        public List <Region> GetRegionByIdCountry(int id)
        {
            Sell_BuyEntities db = new Sell_BuyEntities();
            var regionToCountry = (from r in db.Regions
                                   where r.id_country == id
                                   select r).ToList();

            return(regionToCountry);
        }
        public List <City> GetCityByIdRegion(int id)
        {
            Sell_BuyEntities db = new Sell_BuyEntities();
            var regionToCountry = (from r in db.Cities
                                   where r.id_region == id
                                   select r).ToList();

            return(regionToCountry);
        }
        public List <string> GetDirection(int id)
        {
            Sell_BuyEntities db            = new Sell_BuyEntities();
            List <string>    userDirection = new List <string>();
            var us = (from u in db.Users
                      where u.id == id
                      select u).ToList();

            userDirection.Add(us[0].Country.name_country);
            userDirection.Add(us[0].Region.name_region);
            userDirection.Add(us[0].City.name_sity);
            return(userDirection);
        }
 public string InsertRegion(Region region)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         db.Regions.Add(region);
         db.SaveChanges();
         return(region.name_region + " was succefully inserted");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
Exemple #8
0
 public string InsertLanguage(Language language)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         db.Languages.Add(language);
         db.SaveChanges();
         return(language.translate + "was succefully inserted");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
Exemple #9
0
 public string InsertLastView(LastView lastview)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         db.LastViews.Add(lastview);
         db.SaveChanges();
         return("was succefully inserted");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
Exemple #10
0
 public int InsertMagazine(Magazine magazine)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         db.Magazines.Add(magazine);
         db.SaveChanges();
         return(magazine.id);
     }
     catch (Exception e)
     {
         return(0);
     }
 }
 public string InsertCountry(Country country)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         db.Countries.Add(country);
         db.SaveChanges();
         return(country.name_country + "was succefully inserted");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
 public string InsertBrand(Brand brand)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         db.Brands.Add(brand);
         db.SaveChanges();
         return(brand.name_brand + "was succefully inserted");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
Exemple #13
0
 public string InsertBasket(Basket basket)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         db.Baskets.Add(basket);
         db.SaveChanges();
         return(basket.Product.name + "was succefully inserted");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
 public string InsertRegion(City sity)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         db.Cities.Add(sity);
         db.SaveChanges();
         return(sity.name_sity + " was succefully inserted");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
 public string InsertComments(Comment comment)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         db.Comments.Add(comment);
         db.SaveChanges();
         return(comment.comment1 + "was succefully inserted");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
 public string UpdateBasket(int id, Brand brand)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         Brand            b  = db.Brands.Find(id);
         b.name_brand = brand.name_brand;
         db.SaveChanges();
         return(b.name_brand + "was succefully updated");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
Exemple #17
0
 public Basket GetBasket(int id)
 {
     try
     {
         using (Sell_BuyEntities db = new Sell_BuyEntities())
         {
             Basket basket = db.Baskets.Find(id);
             return(basket);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public List <string> GetCountiesName()
 {
     try
     {
         using (Sell_BuyEntities db = new Sell_BuyEntities())
         {
             List <string> country = db.Countries.Select(d => d.name_country).ToList();
             return(country);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public Region GetRegion(int id)
 {
     try
     {
         using (Sell_BuyEntities db = new Sell_BuyEntities())
         {
             Region region = db.Regions.Find(id);
             return(region);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public string UpdateCountry(int id, Country country)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         Country          c  = db.Countries.Find(id);
         c.name_country = country.name_country;
         db.SaveChanges();
         return(c.name_country + "was succefully updated");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
 public Country GetCountry(int id)
 {
     try
     {
         using (Sell_BuyEntities db = new Sell_BuyEntities())
         {
             Country country = db.Countries.Find(id);
             return(country);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #22
0
 public bool InsertUserShop(Shop us_m)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         db.Shops.Add(us_m);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         nLog.WriteLog("DB_Entity_DAL -> DB_Operation -> DB_Shop -> InsertUserShop :\r\n Message: " + e.Message + "\r\n " + e.StackTrace + "", 0);
         return(false);
     }
 }
Exemple #23
0
 public Product GetProduct(int id)
 {
     try
     {
         using (Sell_BuyEntities db = new Sell_BuyEntities())
         {
             Product product = db.Products.Find(id);
             return(product);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #24
0
 public string UpdateBasket(int id, Basket basket)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         Basket           b  = db.Baskets.Find(id);
         b.id_user    = basket.id_user;
         b.id_product = basket.id_product;
         db.SaveChanges();
         return(b.id_product.Value + "was succefully updated");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
Exemple #25
0
 public List <Product> GetallProducts()
 {
     try
     {
         using (Sell_BuyEntities db = new Sell_BuyEntities())
         {
             List <Product> products = (from x in db.Products
                                        select x).ToList();
             return(products);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #26
0
 public List <Language> GetallLanguages()
 {
     try
     {
         using (Sell_BuyEntities db = new Sell_BuyEntities())
         {
             List <Language> language = (from x in db.Languages
                                         select x).ToList();
             return(language);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public List <Comment> GetallComments()
 {
     try
     {
         using (Sell_BuyEntities db = new Sell_BuyEntities())
         {
             List <Comment> comment = (from x in db.Comments
                                       select x).ToList();
             return(comment);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public List <City> GetallCity()
 {
     try
     {
         using (Sell_BuyEntities db = new Sell_BuyEntities())
         {
             List <City> sity = (from x in db.Cities
                                 select x).ToList();
             return(sity);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #29
0
 public string UpdateLanguage(int id, Language language)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         Language         l  = db.Languages.Find(id);
         l.translate = language.translate;
         l.C_status  = language.C_status;
         db.SaveChanges();
         return(l.translate + "was succefully updated");
     }
     catch (Exception e)
     {
         return("Error:" + e.Message);
     }
 }
Exemple #30
0
 public List <Magazine> GetallMagazine()
 {
     try
     {
         using (Sell_BuyEntities db = new Sell_BuyEntities())
         {
             List <Magazine> magazine = (from x in db.Magazines
                                         select x).ToList();
             return(magazine);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }