public ActionResult <Customer> CreateCustomer(Customer cust) { _repoCust.CreateCustomer(cust); _repoCust.SaveChanges(); return(CreatedAtRoute(nameof(GetCustomerById), new { Id = cust.Id }, cust)); }
public ActionResult <Customer> CreateCustomer(CustomerPostDto customerCreateDto) { var customerModel = _mapper.Map <Customer>(customerCreateDto); _repository.CreateCustomer(customerModel); _repository.SaveChanges(); return(CreatedAtRoute("GetCommandById", new { Id = customerModel.Id }, customerModel)); }
public ActionResult <CustomerReadDto> CreateCustomer(CustomerCreateDto customerCreateDto) { var customerModel = _mapper.Map <customer>(customerCreateDto); _customer.CreateCustomer(customerModel); _customer.SaveChanges(); var customerReadDto = _mapper.Map <CustomerReadDto>(customerModel); return(CreatedAtRoute(nameof(GetCustomerById), new { Id = customerReadDto.CustomerId }, customerReadDto)); }
public IActionResult Post([FromBody] Customer customer) { try { return(Ok(_custRepo.CreateCustomer(customer))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task <HttpResponseMessage> Createcus(CreateCustomer model) { using (HttpClient clients = clientAddress.getCustomerService()) { var jsonstring = JsonConvert.SerializeObject(model); var obj = new StringContent(jsonstring, System.Text.Encoding.UTF8, "application/json"); var response = await clients.PostAsync("api/Customer/Creation", obj); if (response.StatusCode == System.Net.HttpStatusCode.OK) { CustomerDbo dbo = new CustomerDbo() { CustomerId = model.CustomerId, Name = model.Name, PANno = model.PANno, Address = model.Address, DOB = model.DateOfBirth }; _customerRepo.CreateCustomer(dbo); } return(response); } }