public IActionResult Add(Customer customer)
        {
            var result = _customerServices.Add(customer);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
        public IActionResult Create(OrderCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var newOrder = new DTO.Order();
                newOrder.OrderOwner = model.OrderOwner != null ? model.OrderOwner : "";
                newOrder.LocationId = model.SelectedLocationId;

                var dto = _customerServices.Add(newOrder);

                return(RedirectToAction("Tracker", new { id = dto.OrderId }));
            }

            return(View());
        }
        public IActionResult Put([FromBody] Customer customer)
        {
            try
            {
                _customerServices.Add(customer);

                return(new ObjectResult(customer));
            }
            catch (ArgumentNullException ex)
            {
                return(NotFound(ex));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Beispiel #4
0
        public ActionResult Create([Bind(Include = "FirstName, LastName, Address, PhoneNumber, CustomerType")]
                                   CustomerDTO model)
        {
            if (ModelState.IsValid)
            {
                model.AccountNumber = _customerServices.GenerateAccountNumber();
                model.RentedBooks   = 0;

                var customer = DependencyResolver.Current.GetService <ICustomer>();
                Mapper.Map(model, customer);

                _customerServices.Add(customer);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Beispiel #5
0
        public IActionResult Add(CustomerAddModel customerAddModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(customerAddModel));
            }

            else
            {
                Customer customer = new Customer   //GELEN MODEL İLE NESNE OLUŞTUR
                {
                    CustomerName     = customerAddModel.Name,
                    CustomerLastname = customerAddModel.Lastname,
                    City             = customerAddModel.City,
                    Country          = customerAddModel.Country,
                    Adress           = customerAddModel.Adress,
                    Phone            = customerAddModel.Phone
                };

                ICustomerService.Add(customer);     //VERİTABANINA EKLE
                return(RedirectToAction("Index"));  //SAYFAYIYENİLE
            }
        }
Beispiel #6
0
 public string Post([FromBody] Customer customer)
 {
     return(_customerServices.Add(customer));
 }