Beispiel #1
0
 public CustomerModel(Customer customer)
 {
     Id = customer.Id;
     FirstName = customer.FirstName;
     LastName = customer.LastName;
     Email = customer.Email;
 }
Beispiel #2
0
        public void Update(Customer customer)
        {
            if (!CanUseEmail(customer, customer.Email))
                throw new BusinessRuleViolationException("Email was already taken by others.");

            _customerRepository.Update(customer);
            Event.Raise(new CustomerUpdated(customer), _instance);
        }
Beispiel #3
0
 public CustomerRowModel(Customer customer, int orders)
 {
     Id = customer.Id;
     Name = customer.FullName;
     if (string.IsNullOrEmpty(Name.Trim()))
         Name = customer.AccountId;
     Email = customer.Email;
     Orders = orders;
 }
Beispiel #4
0
        public static ShoppingCart Create(Customer customer)
        {
            Require.NotNull(customer, "customer");

            return new ShoppingCart
            {
                Customer = customer
            };
        }
Beispiel #5
0
 public OrderModel(Order order, Customer customer)
 {
     Id = order.Id;
     CustomerFirstName = customer.FirstName;
     CustomerLastName = customer.LastName;
     Total = order.Total;
     CreatedAtUtc = order.CreatedAtUtc;
     Status = order.Status;
     ProcessingStatus = order.ProcessingStatus;
 }
Beispiel #6
0
 public CustomerDeleted(Customer customer)
 {
     CustomerId = customer.Id;
 }
 public ActionResult Save(Customer obj)
 {
     try
     {
         _customerService.Save(obj);
         return this.JsonNet(new { status = 0, message = "customer succssfully saved." });
     }
     catch (Exception ex)
     {
         return this.JsonNet(new { status = 1, message = ex.Message });
     }
 }
 public ActionResult Get(int? id = null)
 {
     var obj = id == null ? null : _customerService.GetById(id.Value);
     if (obj == null)
     {
         obj = new Customer();
     }
     return JsonNet(obj);
 }
 public override bool CanExecute(Kooboo.Commerce.Customers.Customer customer, CommerceInstance instance)
 {
     return(true);
 }
Beispiel #10
0
 public void Delete(Customer customer)
 {
     _customerRepository.Delete(customer);
     Event.Raise(new CustomerDeleted(customer), _instance);
 }
Beispiel #11
0
 public CustomerCreated(Customer customer)
 {
     CustomerId = customer.Id;
 }
Beispiel #12
0
        public static ShoppingCart Create(Customer customer, string sessionId)
        {
            Require.NotNull(customer, "customer");

            return new ShoppingCart
            {
                Customer = customer,
                SessionId = sessionId
            };
        }
Beispiel #13
0
        public void Save(CustomerEditorModel model)
        {
            Customer customer = null;

            if (model.Id > 0)
            {
                customer = _customerService.Find(model.Id);
            }
            else
            {
                customer = new Customer();
            }

            customer.Email = model.Email;

            customer.FirstName = model.FirstName;
            customer.LastName = model.LastName;
            customer.Group = model.Group;
            customer.SavingPoints = model.SavingPoints;
            customer.Gender = model.Gender;

            customer.CustomFields.Clear();

            foreach (var field in model.CustomFields)
            {
                customer.CustomFields.Add(new CustomerCustomField(field.Name, field.Value));
            }

            if (model.Id > 0)
            {
                _customerService.Update(customer);
            }
            else
            {
                _customerService.Create(customer);
            }

            foreach (var address in customer.Addresses.ToList())
            {
                if (!model.Addresses.Any(it => it.Id == address.Id))
                {
                    customer.Addresses.Remove(address);
                }
            }

            foreach (var addressModel in model.Addresses)
            {
                var address = customer.Addresses.FirstOrDefault(it => it.Id == addressModel.Id);
                if (address == null)
                {
                    address = new Address();
                    customer.Addresses.Add(address);
                }

                UpdateAddress(address, addressModel);
            }

            _customerService.Update(customer);
        }
Beispiel #14
0
 private bool CanUseEmail(Customer customer, string email)
 {
     return !_customerRepository.Query().Any(c => c.Id != customer.Id && c.Email == email);
 }
Beispiel #15
0
 public CustomerUpdated(Customer customer)
 {
     CustomerId = customer.Id;
 }
 public abstract bool CanExecute(Customer customer, CommerceInstance instance);
 public RecentOrderedCustomer(Customer customer)
     : base(customer)
 {
 }
Beispiel #18
0
 public void AddAddress(Customer customer, Address address)
 {
     customer.Addresses.Add(address);
     _customerRepository.Database.SaveChanges();
 }