Exemplo n.º 1
0
        public DbResponse AddressAdd(CustomerAddressBookModel model, string userName)
        {
            try
            {
                if (string.IsNullOrEmpty(model.Address))
                {
                    return(new DbResponse(false, "Invalid Data"));
                }

                if (_db.Customer.IsThreeAddressSaved(model.CustomerId))
                {
                    return(new DbResponse(false, "Already three address added"));
                }

                var customerId = _db.Registration.CustomerIdByUserName(userName);

                if (customerId == 0)
                {
                    return(new DbResponse(false, "Invalid User"));
                }

                model.CustomerId = customerId;
                _db.Customer.AddressAdd(model);
                _db.SaveChanges();

                return(new DbResponse(true, "Success"));
            }
            catch (Exception e)
            {
                return(new DbResponse(false, e.Message));
            }
        }
Exemplo n.º 2
0
        public IActionResult PostShippingAddress(CustomerAddressBookModel model)
        {
            var response = _customer.AddressAdd(model, User.Identity.Name);

            return(Json(response));
        }