Пример #1
0
    public static List <Customer> GetAllCustomer()
    {
        using (var context = new WebsiteTTKEntities())
        {
            List <Customer> customers = new List <Customer>();
            var             users     = context.AspNetUsers.ToList();
            foreach (var user in users)
            {
                Customer          customer = new Customer();
                AspNetUserAddress address  = context.AspNetUserAddresses.SingleOrDefault(x => x.UserId == user.Id);
                customer.AspNetUserAddress = address;
                customer.AspNetUser        = user;
                string globalDateFormat = System.Configuration.ConfigurationManager.AppSettings["GlobalDateFormat"];
                customer.Birthday = address.Birthday.Value.ToString(globalDateFormat);
                customer.City     = address.City;
                List <string> countries = Helper.GetCountries();
                if (countries != null)
                {
                    customer.Countries = countries.ToArray();
                }
                customer.Email       = user.Email;
                customer.FirstName   = address.Firstname;
                customer.LastName    = address.Lastname;
                customer.PhoneNumber = address.PhoneNumber;
                customer.Street      = address.Street;
                customer.ZipCode     = address.Zip;

                customers.Add(customer);
            }
            return(customers);
        }
    }
Пример #2
0
 public static string UpdateNewOrderShippingCost(string userId, int delivery_id)
 {
     try
     {
         using (var context = new WebsiteTTKEntities())
         {
             order order = context.orders.FirstOrDefault(x => x.customer_id == userId && x.order_status == (int)OrderStatus.Status.New);
             List <order_items> orderItems = context.order_items.Where(x => x.order_id == order.order_id).ToList();
             if (order != null)
             {
                 order.delivery_id = delivery_id;
                 context.SaveChanges();
                 return(null);
             }
             else
             {
                 return("Order doesn't exist!");
             }
         }
     } catch (Exception ex)
     {
         LogHelper.Log("App_Code\\Helper\\OrderHelper.cs", LogHelper.ErrorType.Error, ex);
         return("Cannot update order's shipping cost!");
     }
 }
Пример #3
0
    private void BindData()
    {
        int product_id = 0;

        Int32.TryParse(Request.QueryString["product_id"], out product_id);
        if (product_id > 0)
        {
            using (var context = new WebsiteTTKEntities())
            {
                //Get loged in user info
                System.Threading.Tasks.Task <Microsoft.AspNet.Identity.EntityFramework.IdentityUser> user = null;
                if (User.Identity.IsAuthenticated)
                {
                    var userName    = User.Identity.Name;
                    var userStore   = new Microsoft.AspNet.Identity.EntityFramework.UserStore <Microsoft.AspNet.Identity.EntityFramework.IdentityUser>();
                    var userManager = new Microsoft.AspNet.Identity.UserManager <Microsoft.AspNet.Identity.EntityFramework.IdentityUser>(userStore);
                    user = userManager.FindByNameAsync(userName);
                }

                //Get product data
                ProductControllerModel model = ProductController.GetProductDetailData(product_id, user);
                if (model != null)
                {
                    //Throw data to client for script to generate the interface of product
                    var productDetailJson = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(model);
                    ProductControllerModel_Data.InnerText = productDetailJson;

                    //Because product slider cannot be modify after script carousel is loaded.
                    //Thus, we generate the slider on server first to help slider load before carousel script run.
                    MakeupProduct(model);
                }
            }
        }
    }
Пример #4
0
    public static void Updatecolours(List <colour> colours, bool isUpdateProductImages = false)
    {
        using (var context = new WebsiteTTKEntities())
        {
            foreach (colour item in colours)
            {
                var result = context.colours.SingleOrDefault(b => b.colour_id == item.colour_id);
                if (result != null)
                {
                    result.colour_name        = item.colour_name;
                    result.colour_description = item.colour_description;
                    result.create_date        = item.create_date;

                    context.SaveChanges();
                }
                else
                {
                    context.colours.Add(new colour
                    {
                        colour_name        = item.colour_name,
                        colour_description = item.colour_description,
                        create_date        = item.create_date,
                    });

                    context.SaveChanges();
                }
            }
        }
    }
Пример #5
0
    public static void Updatebrands(List <brand> brands)
    {
        using (var context = new WebsiteTTKEntities())
        {
            foreach (brand item in brands)
            {
                var result = context.brands.SingleOrDefault(b => b.brand_id == item.brand_id);
                if (result != null)
                {
                    result.brand_name        = item.brand_name;
                    result.brand_description = item.brand_description;
                    result.images            = item.images;
                    result.create_date       = item.create_date;
                    context.SaveChanges();
                }
                else
                {
                    context.brands.Add(new brand
                    {
                        brand_name        = item.brand_name,
                        brand_description = item.brand_description,
                        images            = item.images,
                        create_date       = item.create_date,
                    });

                    context.SaveChanges();
                }
            }
        }
    }
Пример #6
0
    /// <summary>
    /// Update customer address
    /// </summary>
    /// <param name="customer">Customer entity</param>
    /// <returns></returns>
    public static string UpdateCustomerAddress(Customer customer)
    {
        try
        {
            AspNetUser        user    = customer.AspNetUser;
            AspNetUserAddress address = customer.AspNetUserAddress;
            using (var context = new WebsiteTTKEntities())
            {
                var existAddress = context.AspNetUserAddresses.FirstOrDefault(x => x.UserId == user.Id);
                existAddress.Firstname   = address.Firstname;
                existAddress.Lastname    = address.Lastname;
                existAddress.Company     = address.Company;
                existAddress.Street      = address.Street;
                existAddress.City        = address.City;
                existAddress.Zip         = address.Zip;
                existAddress.State       = address.State;
                existAddress.PhoneNumber = address.PhoneNumber;
                existAddress.Email       = address.Email;
                existAddress.Country     = address.Country;

                context.SaveChanges();
                return(null);
            }
        } catch (Exception ex)
        {
            return(ex.Message);
        }
    }
Пример #7
0
    public static void Updatecustomers(List <Customer> customers)
    {
        using (var context = new WebsiteTTKEntities())
        {
            foreach (Customer item in customers)
            {
                var userStore = new Microsoft.AspNet.Identity.EntityFramework.UserStore <Microsoft.AspNet.Identity.EntityFramework.IdentityUser>();
                var manager   = new Microsoft.AspNet.Identity.UserManager <Microsoft.AspNet.Identity.EntityFramework.IdentityUser>(userStore);

                var user = manager.FindByIdAsync(item.AspNetUser.Id).Result;
                if (user != null)
                {
                    user.Email       = item.AspNetUser.Email;
                    user.PhoneNumber = item.AspNetUser.PhoneNumber;

                    Microsoft.AspNet.Identity.IdentityResult result = manager.UpdateAsync(user).Result;
                }
                else
                {
                    user = new Microsoft.AspNet.Identity.EntityFramework.IdentityUser()
                    {
                        UserName = item.AspNetUser.UserName, Email = item.AspNetUser.Email, PhoneNumber = item.AspNetUser.PhoneNumber
                    };

                    Microsoft.AspNet.Identity.IdentityResult result = manager.CreateAsync(user, item.Password).Result;
                }
            }
        }
    }
Пример #8
0
    public static procategory GetCategoryById(int category_id)
    {
        using (var context = new WebsiteTTKEntities())
        {
            var result = context.procategories.SingleOrDefault(b => b.category_id == category_id);
            if (result != null)
            {
                procategory item = new procategory();
                item.category_id          = result.category_id;
                item.category_name        = result.category_name;
                item.category_description = result.category_description;
                item.category_images      = result.category_images;
                item.category_url         = result.category_url;
                item.create_date          = result.create_date;
                item.parent_id            = result.parent_id;
                item.is_publish           = result.is_publish;
                item.is_menu       = result.is_menu;
                item.is_label      = result.is_label;
                item.is_collection = result.is_collection;
                item.store_id      = result.store_id;

                return(item);
            }
            return(null);
        }
    }
Пример #9
0
    public static void AddCurrencyData()
    {
        List <string> list = new List <string>();

        foreach (System.Globalization.CultureInfo ci in System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.AllCultures))
        {
            string specName = "(none)";
            try { specName = System.Globalization.CultureInfo.CreateSpecificCulture(ci.Name).Name; }
            catch { }
            list.Add(ci.Name);
        }
        for (int i = 0; i < list.Count; i++)
        {
            if (list[i] != "" && list[i].Contains('-'))
            {
                try
                {
                    var cl = new System.Globalization.CultureInfo(list[i]);
                    using (var context = new WebsiteTTKEntities())
                    {
                        context.currencies.Add(new currency
                        {
                            currency_name   = cl.EnglishName,
                            currency_code   = cl.Name,
                            currency_symbol = cl.NumberFormat.CurrencySymbol
                        });

                        context.SaveChanges();
                    }
                }
                catch { }
            }
        }
    }
Пример #10
0
 /// <summary>
 /// Get AspNetUser by user id
 /// </summary>
 /// <param name="id">user id</param>
 /// <returns></returns>
 public static AspNetUser GetUserByUserId(string id)
 {
     using (var context = new WebsiteTTKEntities())
     {
         //Get product data
         return(context.AspNetUsers.FirstOrDefault(x => x.Id == id));
     }
 }
Пример #11
0
    private void ShowData()
    {
        using (var context = new WebsiteTTKEntities())
        {
            string id         = Request.QueryString["id"];
            string table_name = Request.QueryString["table_name"];
            if (table_name == "products")
            {
                int product_id = -1;
                Int32.TryParse(id, out product_id);
                if (product_id > 0)
                {
                    IQueryable <product> qProductsTable = from t in context.products where t.product_id == product_id
                                                          select t;
                    product objPro = qProductsTable.FirstOrDefault();
                    if (objPro != null)
                    {
                        if (objPro.product_images != null)
                        {
                            Images_Data.InnerText = objPro.product_images;
                        }
                        else
                        {
                            Images_Data.InnerText = "";
                        }
                    }
                }
            }
            else if (table_name == "categories")
            {
                int category_id = -1;
                Int32.TryParse(id, out category_id);
                if (category_id > 0)
                {
                    IQueryable <procategory> qCategoriesTable = from t in context.procategories
                                                                where t.category_id == category_id
                                                                select t;
                    procategory objCat = qCategoriesTable.FirstOrDefault();
                    if (objCat != null)
                    {
                        if (objCat.category_images != null)
                        {
                            Images_Data.InnerText = objCat.category_images;
                        }
                        else
                        {
                            Images_Data.InnerText = "";
                        }
                    }
                }
            }

            string hostURL = Helper.GetHostURL();
            Service_URL.InnerText      = hostURL + "/admin/Services/UploadImageService.asmx";
            Service_URL_Name.InnerText = "/Services/UploadImageService.asmx";
            Host_URL.InnerText         = hostURL;
        }
    }
Пример #12
0
 public static currency GetCurrencyById(int?currency_id)
 {
     using (var context = new WebsiteTTKEntities())
     {
         //Get product data
         var currency = context.currencies.FirstOrDefault(x => x.currency_id == currency_id);
         return(currency);
     }
 }
Пример #13
0
    /// <summary>
    /// Get list of user's address base on address type
    /// </summary>
    /// <param name="id">Address ID</param>
    /// <param name="type">Address Type (Enum)</param>
    /// <returns></returns>
    public static List <AspNetUserAddress> GetUserAddressByUserId(string id, AddressType type)
    {
        using (var context = new WebsiteTTKEntities())
        {
            //Get product data
            IQueryable <AspNetUserAddress> qUserAddressTable = from t in context.AspNetUserAddresses where t.UserId == id && t.AddressType == type.ToString()
                                                               select t; // can you confirm if your context has Tables or MyTables?
            var listOfProducts = qUserAddressTable.Select(s => new {
                Id          = s.Id,
                UserId      = s.UserId,
                Firstname   = s.Firstname,
                Lastname    = s.Lastname,
                Company     = s.Company,
                Street      = s.Street,
                City        = s.City,
                Country     = s.Country,
                State       = s.State,
                Zip         = s.Zip,
                Birthday    = s.Birthday,
                Gender      = s.Gender,
                PhoneNumber = s.PhoneNumber,
                Email       = s.Email,
                AddressType = s.AddressType
            }).ToList();

            List <AspNetUserAddress> addresses = new List <AspNetUserAddress>();
            foreach (var item in listOfProducts)
            {
                AspNetUserAddress address = new AspNetUserAddress();
                address.Id          = item.Id;
                address.UserId      = item.UserId;
                address.Firstname   = item.Firstname;
                address.Lastname    = item.Lastname;
                address.Company     = item.Company;
                address.Street      = item.Street;
                address.City        = item.City;
                address.Country     = item.Country;
                address.State       = item.State;
                address.Zip         = item.Zip;
                address.Birthday    = item.Birthday;
                address.Gender      = item.Gender;
                address.PhoneNumber = item.PhoneNumber;
                address.Email       = item.Email;
                address.AddressType = item.AddressType;

                addresses.Add(address);
            }

            return(addresses);
        }
    }
Пример #14
0
 /// <summary>
 /// Get new created order of customer
 /// </summary>
 /// <param name="userId">user id</param>
 /// <returns></returns>
 public static order GetNewCreatedOrder(string userId)
 {
     try
     {
         using (var context = new WebsiteTTKEntities())
         {
             return(context.orders.FirstOrDefault(x => x.customer_id == userId && x.order_status == (int)OrderStatus.Status.New));
         }
     } catch (Exception ex)
     {
         LogHelper.Log("App_Code\\Helper\\OrderHelper.cs", LogHelper.ErrorType.Error, ex);
         return(null);
     }
 }
Пример #15
0
    /// <summary>
    /// Update or add a new address
    /// </summary>
    /// <param name="addresses">List of address to be updated or added</param>
    public static void UpdateUserAddresses(List <AspNetUserAddress> addresses)
    {
        using (var context = new WebsiteTTKEntities())
        {
            foreach (AspNetUserAddress item in addresses)
            {
                var result = context.AspNetUserAddresses.SingleOrDefault(b => b.Id == item.Id);
                if (result != null)
                {
                    result.Firstname   = item.Firstname;
                    result.Lastname    = item.Lastname;
                    result.Company     = item.Company;
                    result.Street      = item.Street;
                    result.City        = item.City;
                    result.Zip         = item.Zip;
                    result.State       = item.State;
                    result.Country     = item.Country;
                    result.Birthday    = item.Birthday;
                    result.Gender      = item.Gender;
                    result.PhoneNumber = item.PhoneNumber;
                    result.Email       = item.Email;
                    result.AddressType = item.AddressType;

                    context.SaveChanges();
                }
                else
                {
                    context.AspNetUserAddresses.Add(new AspNetUserAddress
                    {
                        UserId      = item.UserId,
                        Firstname   = item.Firstname,
                        Lastname    = item.Lastname,
                        Company     = item.Company,
                        Street      = item.Street,
                        City        = item.City,
                        Zip         = item.Zip,
                        State       = item.State,
                        Country     = item.Country,
                        Birthday    = item.Birthday,
                        Gender      = item.Gender,
                        PhoneNumber = item.PhoneNumber,
                        Email       = item.Email,
                        AddressType = item.AddressType
                    });

                    context.SaveChanges();
                }
            }
        }
    }
Пример #16
0
 /// <summary>
 /// Return all available delivery methods
 /// </summary>
 /// <returns></returns>
 public static List <delivery_methods> GetAllDeliveryMethods()
 {
     try
     {
         using (var context = new WebsiteTTKEntities())
         {
             return(context.delivery_methods.ToList());
         }
     } catch (Exception ex)
     {
         LogHelper.Log("\\App_Code\\Helper\\DeliveryHelper.cs", LogHelper.ErrorType.Error, ex);
         return(null);
     }
 }
Пример #17
0
 //Push data to client
 private void PushDataToClient()
 {
     using (var context = new WebsiteTTKEntities())
     {
         try
         {
             var orders = context.orders.ToList();
             var json   = new JavaScriptSerializer().Serialize(orders);
             Server_Data.InnerText = json;
         }
         catch (Exception ex) {
             LogHelper.Log("WebsiteTTK\\admin\\Orders.aspx.cs", LogHelper.ErrorType.Error, ex);
         }
     }
 }
Пример #18
0
 public static void DeleteCustomerByIds(List <string> deletedIds)
 {
     using (var context = new WebsiteTTKEntities())
     {
         foreach (var id in deletedIds)
         {
             var result = context.AspNetUsers.SingleOrDefault(b => b.Id == id);
             if (result != null)
             {
                 context.AspNetUsers.Attach(result);
                 context.AspNetUsers.Remove(result);
                 context.SaveChanges();
             }
         }
     }
 }
Пример #19
0
 public static void DeleteStoreByIds(List <int> deletedIds)
 {
     using (var context = new WebsiteTTKEntities())
     {
         foreach (var id in deletedIds)
         {
             var result = context.stores.SingleOrDefault(b => b.store_id == id);
             if (result != null)
             {
                 context.stores.Attach(result);
                 context.stores.Remove(result);
                 context.SaveChanges();
             }
         }
     }
 }
Пример #20
0
    //Push data to client
    private void PushDataToClient()
    {
        using (var context = new WebsiteTTKEntities())
        {
            //Get category data
            IEnumerable <procategory> qCategoriesTable = (from s in context.procategories.AsEnumerable()
                                                          select new procategory
            {
                category_id = s.category_id,
                category_name = s.category_name,
                category_description = s.category_description,
                category_images = s.category_images,
                category_url = s.category_url,
                create_date = s.create_date,
                parent_id = s.parent_id,
                is_publish = s.is_publish,
                is_menu = s.is_menu,
                is_label = s.is_label,
                is_collection = s.is_collection,
                store_id = s.store_id
            });

            var categoriesJson = new JavaScriptSerializer().Serialize(qCategoriesTable.ToList());
            Categories_Data.InnerText = categoriesJson;

            //Because the parent categories are also retrieved from the same category table. So we set parent ctegory dropdownlist items as same as items from category table
            Parent_Category_Data.InnerText = categoriesJson;

            //Get category data
            IEnumerable <store> qStoresTable = (from s in context.stores.AsEnumerable()
                                                select new store
            {
                store_id = s.store_id,
                store_name = s.store_name,
                phone = s.phone,
                email = s.email,
                street = s.street,
                city = s.city,
                state = s.state,
                zip_code = s.zip_code
            });

            var storesJson = new JavaScriptSerializer().Serialize(qStoresTable.ToList());
            Stores_Data.InnerText = storesJson;
        }
    }
Пример #21
0
 //Push data to client
 private void PushDataToClient()
 {
     using (var context = new WebsiteTTKEntities())
     {
         IQueryable <brand> qTable = from t in context.brands
                                     select t;  // can you confirm if your context has Tables or MyTables?
         var list = qTable.Select(s => new {
             s.brand_id,
             s.brand_name,
             s.brand_description,
             s.images,
             s.create_date,
         }).ToList();
         var json = new JavaScriptSerializer().Serialize(list);
         Server_Data.InnerText = json;
     }
 }
Пример #22
0
 //Push data to client
 private void PushDataToClient()
 {
     using (var context = new WebsiteTTKEntities())
     {
         //Get product data
         IQueryable <colour> qColoursTable = from t in context.colours
                                             select t; // can you confirm if your context has Tables or MyTables?
         var listOfColours = qColoursTable.Select(s => new
         {
             s.colour_id,
             s.colour_name,
             s.colour_description,
             s.create_date,
         }).ToList();
         var coloursJson = new JavaScriptSerializer().Serialize(listOfColours);
         Colour_Data.InnerText = coloursJson;
     }
 }
Пример #23
0
    public static void Updateorders(List <order> orders)
    {
        using (var context = new WebsiteTTKEntities())
        {
            foreach (order item in orders)
            {
                var result = context.orders.SingleOrDefault(b => b.order_id == item.order_id);
                if (result != null)
                {
                    result.customer_id             = item.customer_id;
                    result.order_status            = item.order_status;
                    result.order_date              = item.order_date;
                    result.required_date           = item.required_date;
                    result.shipped_date            = item.shipped_date;
                    result.store_id                = item.store_id;
                    result.staff_id                = item.staff_id;
                    result.order_discount          = item.order_discount;
                    result.order_discount_is_fixed = item.order_discount_is_fixed;
                    result.delivery_id             = item.delivery_id;
                    result.currency_id             = item.currency_id;
                    context.SaveChanges();
                }
                else
                {
                    context.orders.Add(new order
                    {
                        order_id                = item.order_id,
                        order_status            = item.order_status,
                        order_date              = item.order_date,
                        required_date           = item.required_date,
                        shipped_date            = item.shipped_date,
                        store_id                = item.store_id,
                        staff_id                = item.staff_id,
                        order_discount          = item.order_discount,
                        order_discount_is_fixed = item.order_discount_is_fixed,
                        delivery_id             = item.delivery_id,
                        currency_id             = item.currency_id,
                    });

                    context.SaveChanges();
                }
            }
        }
    }
Пример #24
0
 //Push data to client
 private void PushDataToClient()
 {
     using (var context = new WebsiteTTKEntities())
     {
         List <Customer> customers = CustomerHelper.GetAllCustomer();
         //var list = qTable.Select(s => new {
         //    s.customer_id,
         //    s.first_name,
         //    s.last_name,
         //    s.phone,
         //    s.email,
         //    s.street,
         //    s.city,
         //    s.zip_code,
         //}).ToList();
         var json = new JavaScriptSerializer().Serialize(customers);
         Server_Data.InnerText = json;
     }
 }
Пример #25
0
    public string RemoveImage()
    {
        // convert postdata to dictionary
        string id         = HttpContext.Current.Request.QueryString["id"];
        string image      = HttpContext.Current.Request.QueryString["image"];
        string table_name = HttpContext.Current.Request.QueryString["table"];

        if (table_name == "products")
        {
            int product_id = -1;
            Int32.TryParse(id, out product_id);
            if (product_id > 0)
            {
                using (var context = new WebsiteTTKEntities())
                {
                    IQueryable <product> qProductsTable = from t in context.products
                                                          where t.product_id == product_id
                                                          select t;
                    product objPro = qProductsTable.FirstOrDefault();
                    if (objPro != null)
                    {
                        try
                        {
                            List <string> strList = objPro.product_images.Split(';').ToList();
                            strList.RemoveAll(x => x.StartsWith(@image));
                            objPro.product_images = string.Join(";", strList);
                            ProductHelper.UpdateProducts(new List <product> {
                                objPro
                            }, true);
                            File.Delete(Server.MapPath("~/" + image));
                            return("Remove image successful!");
                        }
                        catch
                        {
                            return("Image doesn't exist!");
                        }
                    }
                }
            }
        }
        return("Image doesn't exist!");
    }
Пример #26
0
 //Push data to client
 private void PushDataToClient()
 {
     using (var context = new WebsiteTTKEntities())
     {
         IQueryable <store> qTable = from t in context.stores
                                     select t; // can you confirm if your context has Tables or MyTables?
         var list = qTable.Select(s => new
         {
             s.store_id,
             s.store_name,
             s.phone,
             s.email,
             s.street,
             s.city,
             s.zip_code,
         }).ToList();
         var json = new JavaScriptSerializer().Serialize(list);
         Server_Data.InnerText = json;
     }
 }
Пример #27
0
    public static void Updatestaffs(List <staff> staffs)
    {
        using (var context = new WebsiteTTKEntities())
        {
            foreach (staff item in staffs)
            {
                var result = context.staffs.SingleOrDefault(b => b.staff_id == item.staff_id);
                if (result != null)
                {
                    result.first_name = item.first_name;
                    result.last_name  = item.last_name;
                    result.phone      = item.phone;
                    result.email      = item.email;
                    result.phone      = item.phone;
                    result.active     = item.active;
                    result.store_id   = item.store_id;
                    result.manager_id = item.manager_id;
                    result.address    = item.address;
                    context.SaveChanges();
                }
                else
                {
                    context.staffs.Add(new staff
                    {
                        staff_id   = item.staff_id,
                        first_name = item.first_name,
                        last_name  = item.last_name,
                        phone      = item.phone,
                        email      = item.email,
                        active     = item.active,
                        store_id   = item.store_id,
                        manager_id = item.manager_id,
                        address    = item.address,
                    });

                    context.SaveChanges();
                }
            }
        }
    }
Пример #28
0
 /// <summary>
 /// Get order's delivery method
 /// </summary>
 /// <param name="delivery_id">Delivery Id</param>
 /// <returns></returns>
 public static delivery_methods GetDeliveryMethodById(int?delivery_id)
 {
     try
     {
         using (var context = new WebsiteTTKEntities())
         {
             if (delivery_id != null)
             {
                 return(context.delivery_methods.FirstOrDefault(x => x.delivery_id == delivery_id));
             }
             else
             {
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         LogHelper.Log("\\App_Code\\Helper\\DeliveryHelper.cs", LogHelper.ErrorType.Error, ex);
         return(null);
     }
 }
Пример #29
0
    public static void Updatestores(List <store> stores)
    {
        using (var context = new WebsiteTTKEntities())
        {
            foreach (store item in stores)
            {
                var result = context.stores.SingleOrDefault(b => b.store_id == item.store_id);
                if (result != null)
                {
                    result.store_name        = item.store_name;
                    result.store_description = item.store_description;
                    result.store_images      = item.store_images;
                    result.phone             = item.phone;
                    result.email             = item.email;
                    result.street            = item.street;
                    result.city     = item.city;
                    result.zip_code = item.zip_code;
                    context.SaveChanges();
                }
                else
                {
                    context.stores.Add(new store
                    {
                        store_id          = item.store_id,
                        store_name        = item.store_name,
                        store_description = item.store_description,
                        store_images      = item.store_images,
                        phone             = item.phone,
                        email             = item.email,
                        street            = item.street,
                        city     = item.city,
                        zip_code = item.zip_code,
                    });

                    context.SaveChanges();
                }
            }
        }
    }
Пример #30
0
 public static List <procategory> GetCategoryByStoreId(int?store_id)
 {
     using (var context = new WebsiteTTKEntities())
     {
         return((from s in context.procategories.AsEnumerable()
                 where s.store_id == store_id
                 select new procategory
         {
             category_id = s.category_id,
             category_name = s.category_name,
             category_description = s.category_description,
             category_images = s.category_images,
             category_url = s.category_url,
             create_date = s.create_date,
             parent_id = s.parent_id,
             is_publish = s.is_publish,
             is_menu = s.is_menu,
             is_label = s.is_label,
             is_collection = s.is_collection,
             store_id = s.store_id
         }).ToList());
     }
 }