public IHttpActionResult Post(CAddressCreate customerAddress, int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = new CustomerAddressService();

            if (!service.CreateCustomerAddress(customerAddress, id))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Esempio n. 2
0
        public bool CreateCustomerAddress(CAddressCreate model, int customerID)
        {
            var entity = new CustomerAddress()
            {
                CustomerAddressID = customerID,
                StreetOne         = model.StreetOne,
                StreetTwo         = model.StreetTwo,
                City    = model.City,
                State   = model.State,
                Zipcode = model.Zipcode,
                Country = model.Country,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.CustomerAddresses.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }