// [EnableCors("allowedOrigins")]
 public IActionResult AddCustomer(Customer customer)
 {
     try
     {
         customerServices.AddCustomer(customer);
         return(CreatedAtAction("AddCustomer", customer));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
예제 #2
0
        public ActionResult <Customers> AddCustomer(Customers customer)
        {
            var customers = _customerServices.AddCustomer(customer);

            if (customers == null)
            {
                return(NotFound());
            }
            return(customers);
        }
        public async Task <IActionResult> Create(Customer customer)
        {
            if (ModelState.IsValid)
            {
                await _customerServices.AddCustomer(customer);

                return(RedirectToAction("Index"));
            }
            return(View(customer));
        }
예제 #4
0
        public ApiResponse <bool> UserRegistration(CustomerBasicDetails customerBasicDetails)
        {
            var customerSummary = _customerServices.GetCustomerSummaryByEmail(customerBasicDetails.Email);

            if (customerSummary == null)
            {
                bool isAdded = _customerServices.AddCustomer(customerBasicDetails);
                return(ApiUtility.ApiSuccess <bool>(isAdded, isAdded ? "New customer added successfully" : "Failed !!!"));
            }
            else
            {
                return(ApiUtility.ApiSuccess <bool>(false, "Email already found"));
            }
        }
예제 #5
0
        public HttpResponseMessage AddCustomer(CustomerOperateDTO dto)
        {
            ResultDTO <object> actionresult = new ResultDTO <object>();

            try
            {
                actionresult.SubmitResult = _ICustomerServices.AddCustomer(dto);
            }
            catch (Exception ex)
            {
                actionresult.SubmitResult = false;
                actionresult.Message      = ex.Message;
            }

            HttpResponseMessage result = new HttpResponseMessage
            {
                Content = new StringContent(JsonConvert.SerializeObject(actionresult),
                                            System.Text.Encoding.GetEncoding("UTF-8"),
                                            "application/json")
            };

            return(result);
        }
예제 #6
0
        public ActionResult Post([FromBody] CustomerItem value)
        {
            // Validation.
            if ((value == null) ||
                (value.Id != string.Empty) ||
                (ModelState.IsValid == false))
            {
                return(BadRequest());
            }

            // Object Flow Validation.
            bool isObjectFlowValid = _iFlowValid.IsValidOperation(BaseValidatorType.Create, value, null);

            if (!isObjectFlowValid)
            {
                return(BadRequest());
            }

            // Add.
            _iCustomerServices.AddCustomer(value);

            // Return.
            return(Created("GetCustomer", value));
        }
 public void Index()
 {
     _customerServices.AddCustomer(new Customer());
 }
 public void Index([FromServices] ICustomerServices customerServices)
 {
     customerServices.AddCustomer(new Customer());
 }