示例#1
0
        /// <summary>
        /// Fills/Creates the user and the related entites with the data choosen by the User
        /// </summary>
        /// <param name="customer">user entity to be modified</param>
        /// <param name="brands">List containing Id's of the customers choosen</param>
        /// <param name="cultureChoosen">List containing Id's of the cultures choosen</param>
        /// <param name="countryChoosen">List containing Id's of the coutries choosen</param>
        /// <returns></returns>
        public Customer createdCustomerData(Customer customer, List<Int32> brands)
        {
            Customer createdCustomer = new Customer();
            createdCustomer.Name = customer.Name;
            createdCustomer.CompanyNumber = customer.CompanyNumber;
            createdCustomer.Website = customer.Website;
            createdCustomer.Comments = customer.Comments;
            createdCustomer.VATNumber = customer.VATNumber;

            #region Customer
            //editedCustomer.Brands.Load();
            //editedCustomer.Brands.Clear();
            if (brands != null)
            {
                List<Brand> brandsAssct = createdCustomer.Brands.ToList();
                foreach (var id in brands)
                {
                    Brand inCheck = _entities.Brands.Where(brand => brand.ID == id).First();
                    if (!brandsAssct.Contains(inCheck))
                    {
                        createdCustomer.Brands.Add(inCheck);
                        //editedUser.Customers.Attach(inCheck);
                    }
                }
            }
            #endregion

            return createdCustomer;
        }
示例#2
0
 /// <summary>
 /// Creates a new Customer
 /// </summary>
 /// <param name="name"></param>
 /// <param name="p"></param>
 public void createCustomer(Customer newCustomer)
 {
     //var User = new User();
     //var lastUser = _entities.Users.ToList().Last();
     //User.ID = lastUser.ID + 1;
     //User.Username = name;
     //User.Logo = path;
     _entities.Customers.AddObject(newCustomer);
     _entities.SaveChanges();
 }
示例#3
0
 public void saveCustomer(Customer customer)
 {
     var Customer = (from b in _entities.Customers
                 where b.ID == customer.ID
                 select b).First();
     Customer = customer;
     //User.Logo = imgPath;
     _entities.SaveChanges();
 }
        public Customer GetCustomer(int userId)
        {
            var user = GetUserByUserId(userId);
            var customer = new Customer()
            {
                //CreatedDate = user.CreatedDate,
                UserId = user.UserId,
                UserType = user.UserType,
                UserName = user.UserName
                //UserTypeId = user.UserTypeId,
                //WordpressUserId = user.WordpressUserId
            };

            return customer;
        }