Пример #1
0
        public async Task <ActionResult> Post([FromBody] CustomerViewModel vm)
        {
            var userName = identityService.GetUserName();

            var response = await _customerService.AddNewCustomer(vm, userName);

            return(Ok(response));
        }
Пример #2
0
 public IActionResult CreateCustomer(Customer customer)
 {
     if (ModelState.IsValid)
     {
         var savingResult = _customerService.AddNewCustomer(customer);
         TempData["CustomerResult"] = savingResult ? "Customer was added successfully!" : "Error!";
         return(RedirectToAction("Index", "Admin"));
     }
     return(View(customer));
 }
Пример #3
0
        public IActionResult AddNewCustomer(Customer customer)
        {
            var result = _customerService.AddNewCustomer(customer);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Пример #4
0
        public JsonResult AddNewCustomer([FromBody] CustomerModel customerModel)
        {
            var customer = CustomerMapper.AddNewCustomer(customerModel);
            var response = customerService.AddNewCustomer(customer);

            return(new JsonResult(response)
            {
                StatusCode = response.StatusCode
            });
        }
Пример #5
0
 public IActionResult AddNewCustomerSummary(CustomerForCreationVm customer)
 {
     if (customer.Btn == "Submit")
     {
         CustomerForSummaryVm customerForSummary = _customerService.AddNewCustomer(customer);
         return(View(customerForSummary));
     }
     else
     {
         return(RedirectToAction("index", "Home"));
     }
 }
Пример #6
0
        public async Task <ActionResult> AddNewCustomer(Customer newCustomer)
        {
            if (ModelState.IsValid)
            {
                var response = await _customerService.AddNewCustomer(newCustomer);

                return(Json(response));
            }
            else
            {
                return(Json(new { success = false, responseText = "Add customer failed" }));
            }
        }
 public ActionResult <CustomerViewModel> Post(CustomerViewModel customerViewModel)
 {
     if (customerViewModel == null)
     {
         return(BadRequest());
     }
     try
     {
         var customer = _customerService.AddNewCustomer(customerViewModel);
         return(Ok(customer));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
        public async Task <ActionResult <CustomerContext> > AddNewCustomer([FromBody] AddNewCustomerRequestModel request)
        {
            var result = await _customerService.AddNewCustomer(request.Email, request.Password);

            return(new OkObjectResult("Customer added"));
        }
        public async Task <IActionResult> AddNewCustomer([FromBody] Customer customer)
        {
            await _customerService.AddNewCustomer(customer);

            return(Ok());
        }