Пример #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);
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
 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);
     }
 }
Пример #4
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);
     }
 }
Пример #5
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);
     }
 }
Пример #6
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);
     }
 }
Пример #7
0
 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);
     }
 }
Пример #8
0
 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);
     }
 }
Пример #9
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);
     }
 }
Пример #10
0
 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);
     }
 }
Пример #11
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);
     }
 }
Пример #12
0
 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);
     }
 }
Пример #13
0
 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);
     }
 }
Пример #14
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);
     }
 }
Пример #15
0
 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);
     }
 }
Пример #16
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);
     }
 }
Пример #17
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);
     }
 }
Пример #18
0
        public string UpdateRegion(int id, Region region)
        {
            try
            {
                Sell_BuyEntities db = new Sell_BuyEntities();
                Region           r  = db.Regions.Find(id);
                r.name_region = region.name_region;
                r.id_country  = region.id_country;

                db.SaveChanges();
                return(r.name_region + " was succefully updated");
            }
            catch (Exception e)
            {
                return("Error:" + e.Message);
            }
        }
Пример #19
0
        public string DeleteCountry(int id)
        {
            try
            {
                Sell_BuyEntities db      = new Sell_BuyEntities();
                Country          country = db.Countries.Find(id);

                db.Countries.Attach(country);
                db.Countries.Remove(country);
                db.SaveChanges();

                return(country.name_country + "was succefully delited");
            }
            catch (Exception e)
            {
                return("Error:" + e.Message);
            }
        }
Пример #20
0
        public string DeleteUser(int id)
        {
            try
            {
                Sell_BuyEntities db   = new Sell_BuyEntities();
                User             user = db.Users.Find(id);

                db.Users.Attach(user);
                db.Users.Remove(user);
                db.SaveChanges();

                return(user.name_last + "was succefully delited");
            }
            catch (Exception e)
            {
                return("Error:" + e.Message);
            }
        }
Пример #21
0
        public string DeleteComments(int id)
        {
            try
            {
                Sell_BuyEntities db      = new Sell_BuyEntities();
                Comment          comment = db.Comments.Find(id);

                db.Comments.Attach(comment);
                db.Comments.Remove(comment);
                db.SaveChanges();

                return(comment.comment1 + "was succefully delited");
            }
            catch (Exception e)
            {
                return("Error:" + e.Message);
            }
        }
Пример #22
0
        public string UpdateComments(int id, Comment comment)
        {
            try
            {
                Sell_BuyEntities db = new Sell_BuyEntities();
                Comment          c  = db.Comments.Find(id);
                c.id_user    = comment.id_user;
                c.id_product = comment.id_product;
                c.comment1   = comment.comment1;

                db.SaveChanges();
                return(c.comment1 + "was succefully updated");
            }
            catch (Exception e)
            {
                return("Error:" + e.Message);
            }
        }
Пример #23
0
        public string DeleteRegion(int id)
        {
            try
            {
                Sell_BuyEntities db   = new Sell_BuyEntities();
                City             sity = db.Cities.Find(id);

                db.Cities.Attach(sity);
                db.Cities.Remove(sity);
                db.SaveChanges();

                return(sity.name_sity + " was succefully delited");
            }
            catch (Exception e)
            {
                return("Error:" + e.Message);
            }
        }
Пример #24
0
        public string UpdateRegion(int id, City sity)
        {
            try
            {
                Sell_BuyEntities db = new Sell_BuyEntities();
                City             s  = db.Cities.Find(id);
                s.id_region  = sity.id_region;
                s.id_country = sity.id_country;
                s.name_sity  = sity.name_sity;

                db.SaveChanges();
                return(s.name_sity + " was succefully updated");
            }
            catch (Exception e)
            {
                return("Error:" + e.Message);
            }
        }
Пример #25
0
        //public void GetAllShopsById(int id)
        //{
        //      try
        //    {
        //        Sell_BuyEntities db = new Sell_BuyEntities();
        //        Magazine magazine = db.Magazines.Find(id);
        //          var roles = db.Shops.Where(x => x.id_user == id).Select(x => x);
        //        //db.Magazines.Attach(magazine);
        //        //db.Magazines.Remove(magazine);
        //        //db.SaveChanges();

        //     //   return magazine.name_magazine + " was succefully delited";
        //    }
        //    catch (Exception e)
        //    {
        //      //  return "Error:" + e.Message;
        //    }

        //}

        public string DeleteMagazine(int id)
        {
            try
            {
                Sell_BuyEntities db       = new Sell_BuyEntities();
                Magazine         magazine = db.Magazines.Find(id);

                db.Magazines.Attach(magazine);
                db.Magazines.Remove(magazine);
                db.SaveChanges();

                return(magazine.name_magazine + " was succefully delited");
            }
            catch (Exception e)
            {
                return("Error:" + e.Message);
            }
        }
Пример #26
0
        public string DeleteLanguage(int id)
        {
            try
            {
                Sell_BuyEntities db       = new Sell_BuyEntities();
                Language         language = db.Languages.Find(id);

                db.Languages.Attach(language);
                db.Languages.Remove(language);
                db.SaveChanges();

                return(language.translate + "was succefully delited");
            }
            catch (Exception e)
            {
                return("Error:" + e.Message);
            }
        }
Пример #27
0
        public string DeleteRegion(int id)
        {
            try
            {
                Sell_BuyEntities db     = new Sell_BuyEntities();
                Region           region = db.Regions.Find(id);

                db.Regions.Attach(region);
                db.Regions.Remove(region);
                db.SaveChanges();

                return(region.name_region + " was succefully delited");
            }
            catch (Exception e)
            {
                return("Error:" + e.Message);
            }
        }
Пример #28
0
        public string DeleteBasket(int id)
        {
            try
            {
                Sell_BuyEntities db     = new Sell_BuyEntities();
                Basket           basket = db.Baskets.Find(id);

                db.Baskets.Attach(basket);
                db.Baskets.Remove(basket);
                db.SaveChanges();

                return(basket.Product.name + "was succefully delited");
            }
            catch (Exception e)
            {
                return("Error:" + e.Message);
            }
        }
Пример #29
0
 public string UpdateMagazine(int id, Magazine magazine)
 {
     try
     {
         Sell_BuyEntities db = new Sell_BuyEntities();
         var m = db.Magazines.FirstOrDefault(u => u.id == id);
         m.name_magazine = magazine.name_magazine;
         m.C_password    = magazine.C_password;
         m.id_category   = magazine.id_category;
         //m.C_status = magazine.C_status;
         db.SaveChanges();
         return(m.name_magazine + " was succefully updated");
     }
     catch (Exception e)
     {
         nLog.WriteLog("DB_Entity_DAL -> DB_Operation -> DB_Country -> GetallCountries :\r\n Message: " + e.Message + "\r\n " + e.StackTrace, 0);
         return("Error");
     }
 }
Пример #30
0
        public string UpdateInfoSurnameProfile(int _iduser, string _newsurname)
        {
            string getResult = "";

            try
            {
                Sell_BuyEntities db = new Sell_BuyEntities();
                var result          = db.Users.SingleOrDefault(u => u.id == _iduser);
                if (result != null)
                {
                    result.name_first = _newsurname;
                    db.SaveChanges();
                    getResult = "Фамилия успешно изменена на " + _newsurname;
                }
            }
            catch (Exception e)
            {
                getResult = "Error !";
                nLog.WriteLog("DB_Entity_DAL -> DB_Operation -> DB_User -> UpdateInfoSurnameProfile :\r\n Message: " + e.Message + "\r\n " + e.StackTrace + "", 0);
            }
            return(getResult);
        }