public CustomerForSummaryVm AddNewCustomer(CustomerForCreationVm customerVm)
        {
            CustomerForCreationVm newCustomer = _addressService.SetInitialContactsAndAddressesTypes(customerVm);
            Customer customer = _mapper.Map <Customer>(newCustomer);

            return(GetLastAddedCustomer(_customerRepository.AddNewCustomer(customer)));
        }
        public IActionResult Create(CustomerEditViewModel model)
        {
            string uniqueFile = null;

            if (ModelState.IsValid)
            {
                if (model.Photo != null)
                {
                    string folderPath = Path.Combine(_environment.WebRootPath, "images");
                    uniqueFile = Guid.NewGuid().ToString() + "_" + model.Photo.FileName;
                    string filePath = Path.Combine(folderPath, uniqueFile);
                    model.Photo.CopyTo(new FileStream(filePath, FileMode.Create));
                }
                Customer newCustomer = new Customer()
                {
                    Name      = model.Name,
                    Email     = model.Email,
                    Gender    = model.Gender,
                    PhotoPath = uniqueFile
                };
                _customerRepository.AddNewCustomer(newCustomer);
                return(RedirectToAction("PrintDetails", new { id = newCustomer.Id }));
            }
            return(View());
        }
Exemple #3
0
        public IActionResult Create([Bind("Id,Name,PhoneNumber,DateOfBirth,Address,Town,County")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _customerRepository.AddNewCustomer(customer);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Exemple #4
0
        public void CreateCustomer(CustomerDTO customer)
        {
            var entity = new Customer(
                customer.Name, customer.Address, customer.IsActive
                );

            _customerRepository.AddNewCustomer(entity);
            _unitOfWork.CommitChanges();
            customer.Id = entity.Id;
        }
        public CustomerDTO CreateNewCustomer(CustomerDTO newCustomerDTO)
        {
            foreach (var item in newCustomerDTO.GetType().GetProperties())
            {
                if (item.Name != "Id")
                {
                    if ((item.GetValue(newCustomerDTO) == null))
                    {
                        throw new CustomerInputException();
                    }
                }
                else
                {
                    if ((item.GetValue(newCustomerDTO).ToString() != "-1"))
                    {
                        throw new CustomerInputException();
                    }
                }
            }
            Customer newCustomer = _customerMapper.FromCustomerDTOToCustomer(newCustomerDTO);

            _customerRepository.AddNewCustomer(newCustomer);
            return(_customerMapper.FromCustomerToCustomerDTO(newCustomer));
        }
Exemple #6
0
 public Response AddNewCustomer(Customer customer)
 {
     return(customerRepository.AddNewCustomer(customer));
 }
 public IActionResult CreateCustomer([FromBody] Customer customer)
 {
     _customerRepository.AddNewCustomer(customer);
     return(Ok());
 }
Exemple #8
0
 public CustomerViewModel AddNewCustomer(CustomerViewModel customerViewModel)
 {
     return(_customerRepository.AddNewCustomer(customerViewModel));
 }