public IActionResult Add(Customer customer) { var result = _customerService.AddCustomer(customer); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task Post([FromBody] Users value) { try { await _service.AddCustomer(value); } catch (Exception ex) { } }
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)); } }
public void AddCustomer(string customerAlias) { var customer = new Customer(); if (ModelState.IsValid) { customer.CustomerAlias = customerAlias; customer.IsActive = true; _customerService.AddCustomer(customer); } }
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)); }
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)); }
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); } }
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 })); }
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)); } }
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()); }
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)); }
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)); } }
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))); }
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()); } }
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); } }
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")); }
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))); }
private void AddCustomer() { bool added = service.AddCustomer(ID, Name); if (added) { text = "Customer added"; } else { text = "Cannot add Customer"; } MessageBoxShowDelegate(Text); }