Exemplo n.º 1
0
        public IActionResult Add(Customer customer)
        {
            var result = _customerService.AddCustomer(customer);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Exemplo n.º 2
0
 public async Task Post([FromBody] Users value)
 {
     try
     {
         await _service.AddCustomer(value);
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 3
0
        private Customer AddCustomer()
        {
            Customer customer = new Customer
            {
                Email = "*****@*****.**",
                Name  = "Locador X"
            };

            return(_customerService.AddCustomer(customer).Result);
        }
 public int AddCustomer([FromBody] CustomerViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(0);
     }
     else
     {
         return(_iCustomerService.AddCustomer(model));
     }
 }
 public ActionResult <Customer> Post([FromBody] Customer customer)
 {
     try
     {
         return(Ok(_customerService.AddCustomer(customer)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemplo n.º 6
0
        public void AddCustomer(string customerAlias)
        {
            var customer = new Customer();

            if (ModelState.IsValid)
            {
                customer.CustomerAlias = customerAlias;
                customer.IsActive      = true;
                _customerService.AddCustomer(customer);
            }
        }
Exemplo n.º 7
0
        public ActionResult AddCustomer(AddCustomerViewModel model)
        {
            if (ModelState.IsValid)
            {
                var customer = Mapper.Map <Customer>(model);
                var result   = _customerService.AddCustomer(customer);
                return(Json(result, JsonRequestBehavior.AllowGet));
            }

            return(Json("", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        public Customer Post([FromBody] Customer customer)
        {
            bool validId = Guid.TryParse(User.FindFirst("sub")?.Value, out Guid customerId);

            if (!validId)
            {
                throw new Exception("Invalid user id");
            }

            return(_customerService.AddCustomer(customerId, customer));
        }
        public async Task <ActionResult <Customer> > CreateCustomer()
        {
            var customer = new Customer
            {
                Age       = 30,
                FirstName = "Wolfgang",
                LastName  = "Ofner"
            };

            return(await _customerService.AddCustomer(customer));
        }
Exemplo n.º 10
0
 public ActionResult AddCustomer(CustomerDetailModel model)
 {
     try
     {
         return(Json(new { Success = _customerService.AddCustomer(model), }));
     }
     catch (Exception ex)
     {
         return(Json(new { Success = false, Messages = ex.Message }));
     }
 }
 public async Task <int?> AddNewCustomer(Customer customer)
 {
     try
     {
         return(await _customerService.AddCustomer(customer));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
         return(null);
     }
 }
Exemplo n.º 12
0
 public IActionResult Customer([FromBody] MvCustomer customer)
 {
     try
     {
         string json = customerService.AddCustomer(customer);
         return(Ok(json));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public ActionResult AddOrUpdateCustomer(int formId, Customer customer)
 {
     if (customer.Id == 0)
     {
         _customerService.AddCustomer(customer);
     }
     else
     {
         _customerService.UpdateCustomer(customer);
     }
     return(RedirectToAction("Browse", "Form", new { formId, customer.Id }));
 }
Exemplo n.º 14
0
 public string AddCustomer(CustomerCompany customer)
 {
     try
     {
         return(_customerService.AddCustomer(customer));
     }
     catch (Exception ex)
     {
         Log.Write(ex);
         throw;
     }
 }
 public IActionResult NewCustomer([FromBody] Customer customer)
 {
     try
     {
         var result = customerService.AddCustomer(customer);
         return(Ok(result));
     }
     catch (Exception e)
     {
         return(Ok(e.Message));
     }
 }
Exemplo n.º 16
0
 public ActionResult Post([FromBody] CustomerDto customer)
 {
     if (customer.Addresses.FirstOrDefault(a => a.IsPostalAddress) == null)
     {
         return(BadRequest("No postal addresss"));
     }
     if (_customerService.AddCustomer(customer))
     {
         return(Ok());
     }
     return(BadRequest());
 }
Exemplo n.º 17
0
        public void CreateOrder_Success()
        {
            var p0 = new AddProductOptions()
            {
                Name     = "p0name",
                Price    = 1230M,
                Category = ProductCategory.Cameras,
                Id       = $"Test{CodeGenerator.CreateRandom()}"
            };

            var p1 = new AddProductOptions()
            {
                Name     = "p1name",
                Price    = 1230M,
                Category = ProductCategory.Cameras,
                Id       = $"Test{CodeGenerator.CreateRandom()}"
            };

            Assert.True(products_.AddProduct(p0));
            Assert.True(products_.AddProduct(p1));

            var customer = customers_
                           .AddCustomer(new AddCustomerOptions()
            {
                Email     = $"{CodeGenerator.CreateRandom()}@test.com",
                VatNumber = $"{CodeGenerator.CreateRandom()}"
            }
                                        );

            Assert.NotNull(customer);

            var productIds = new List <string> {
                p0.Id, p1.Id
            };

            var order = orders_.CreateOrder(
                customer.Id, productIds);

            Assert.NotNull(order);

            var dbOrder = context_.Set <Order>().Find(order.Id);

            Assert.NotNull(dbOrder);

            Assert.True(customer.Id == dbOrder.Customer.Id);

            foreach (var p in productIds)
            {
                Assert.Contains(dbOrder.Products
                                .Select(prod => prod.ProductId), prod => prod.Equals(p));
            }
        }
        public async Task <ActionResult <CustomerViewModel> > AddCustomer(Customer1ViewModel customer1ViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            CustomerViewModel customerViewModel =
                _mapper.Map <CustomerViewModel>(
                    await _customerService.AddCustomer(_mapper.Map <Customer>(customer1ViewModel)));

            return(CustomResponse(customerViewModel));
        }
Exemplo n.º 19
0
        public ActionResult Create(CustomerViewModel customer)
        {
            try
            {
                customerService.AddCustomer(customer);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult AddCustomer(Customer newCustomer)
        {
            var result = _service.AddCustomer(newCustomer);

            if (!String.IsNullOrEmpty(result))
            {
                return(BadRequest(result));
            }
            else
            {
                return(Ok(result));
            }
        }
Exemplo n.º 21
0
 public async Task <IActionResult> AddCustomer(string name)
 {
     try
     {
         _logger.LogDebug($"Request To Add Customer with name: {name}");
         return(Ok(await _customerService.AddCustomer(name)));
     }
     catch (Exception e)
     {
         _logger.LogError($"{e}");
         return(StatusCode((int)HttpStatusCode.InternalServerError));
     }
 }
        public CustomerDto GetCustomer(CustomerDto customerDto)
        {
            CardBuilder cardBuilder = new CardBuilder();

            cardBuilder.WithCcv(customerDto.Card.Ccv);
            cardBuilder.WithNumber(customerDto.Card.Number);

            CustomerBuilder customerBuilder = new CustomerBuilder();

            customerBuilder.WithName(customerDto.Nome);
            customerBuilder.WithCard(cardBuilder.Instance);
            return(_mapper.Map <CustomerDto>(_service.AddCustomer(customerBuilder.Instance)));
        }
Exemplo n.º 23
0
        public AddCustomerResponse AddCustomer([FromBody] AddCustomerRequest request)
        {
            try
            {
                if (request.Name == null || request.Surname == null || request.PhoneNumber == null)
                {
                    throw new ArgumentException("Name, Surname or Phone_number can't be empty.");
                }

                return(new AddCustomerResponse
                {
                    Error = _customerService.AddCustomer(request)
                });
            }
            catch (Exception e)
            {
                return(new AddCustomerResponse
                {
                    Error = e.Message
                });
            }
        }
 public IActionResult AddCustomer(CustomerResource newCustomer)
 {
     try
     {
         _customerService.AddCustomer(_mapper.ParseCustomer(newCustomer));
         _customerService.SaveChanges();
         return(CreatedAtAction("AddCustomer", newCustomer));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Exemplo n.º 25
0
        private void AddCustomer(string customerAlias, string email, int profileId)
        {
            var customer = new Customer();

            if (ModelState.IsValid)
            {
                customer.CustomerAlias = customerAlias;
                customer.UserProfileId = profileId;
                customer.IsActive      = true;
                customer.ContactEmail  = email;

                _customerService.AddCustomer(customer);
            }
        }
Exemplo n.º 26
0
        public ActionResult Register(CustomerModel customerModel)
        {
            if (!ModelState.IsValid)
            {
                //这个地方可以返回错误页面
                return(Content(ModelState.ToErrorMessage()));
            }

            var customer = _mapper.Map <Customer>(customerModel);

            customer.CreateTime = DateTime.Now;
            _customerService.AddCustomer(customer);
            return(Content("ok"));
        }
Exemplo n.º 27
0
        public async Task <IActionResult> AddCustomer(Customer newCustomer)
        {
            var result = await _customerService.AddCustomer(newCustomer);

            if (result.Status == 200)
            {
                return(Ok(result.Payload));
            }
            if (result.Status == 400)
            {
                return(BadRequest(result.ErrorDescription));
            }
            return(BadRequest());
        }
        public bool AddCustomer()
        {
            var model = new CustomerModel
            {
                Id           = _newId,
                Address      = "江苏昆山",
                KnownDate    = DateTime.Now,
                LevelId      = Guid.Empty,
                MobileNumber = "15900000000",
                Name         = "江都电子有限公司"
            };

            return(_customerService.AddCustomer(model));
        }
        public IActionResult AddCustomer(CustomerDetailDto customerDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var customerBl = _mapper.Map <CustomerBl>(customerDto);

            customerBl = _customers.AddCustomer(customerBl);

            return(Created(new Uri(Request.GetDisplayUrl() + customerBl.CustomerId),
                           _mapper.Map <CustomerDetailDto>(customerBl)));
        }
Exemplo n.º 30
0
        private void AddCustomer()
        {
            bool added = service.AddCustomer(ID, Name);

            if (added)
            {
                text = "Customer added";
            }
            else
            {
                text = "Cannot add Customer";
            }
            MessageBoxShowDelegate(Text);
        }