public void AddCustomerTest() { Customer customer = new Customer(101, "Matt", "Knox"); repository.AddCustomer(customer); Assert.AreEqual(1, repository.GetAllCustomers().Count); }
public IActionResult AddCustomer(Customers customers) { try { _logger.LogInformation("اجرای متد AddCustomer"); if (!ModelState.IsValid) { var errors = ModelState.Values.SelectMany(a => a.Errors).Select(a => a.ErrorMessage); _logger.LogError("Model in Not valid"); return(BadRequest(string.Join(",", errors))); } var result = _customer.AddCustomer(new Customers { FName = customers.FName, LName = customers.LName, Mobile = customers.Mobile, Address = customers.Address, StatusCustomer = customers.StatusCustomer, PasswordCustomer = customers.PasswordCustomer, CustomerCreateDate = DateTime.Now }); if (result.IsSucceed) { _logger.LogInformation("کاربر با موفقیت اضافه شد"); return(Ok(result.Data)); } return(BadRequest(string.Join(",", result.Errors))); } catch (Exception) { throw; } }
public void Post(Customer customer) { if (ModelState.IsValid) { context.AddCustomer(customer); } }
public IActionResult AddMedicine(Customers customers) { _customers.AddCustomer(customers); return(Created(HttpContext.Request.Scheme + "://" + HttpContext.Request.Host + HttpContext.Request.Path + "/" + customers.CId, customers)); }
public ActionResult Create(CustomerViewModel customerViewModel) { try { if (ModelState.IsValid) { var isCustomer = _iCustomer.CheckCustomernameExists(customerViewModel.CustomerEmail); if (isCustomer) { ModelState.AddModelError("", "Customer already exists"); } AesAlgorithm aesAlgorithm = new AesAlgorithm(); var customer = AutoMapper.Mapper.Map <Customers>(customerViewModel); customer.Status = true; customer.CustomerID = 0; customer.CreatedBy = Convert.ToInt32(Session["UserID"]); var customerId = _iCustomer.AddCustomer(customer); if (customerId != -1) { var passwordMaster = new PasswordMaster { CreateDate = DateTime.Now, UserId = customerId, PasswordId = 0, Password = aesAlgorithm.EncryptString(customerViewModel.Password), UserEmail = customerViewModel.CustomerEmail }; var passwordId = _iPassword.SavePassword(passwordMaster); if (passwordId != -1) { var savedAssignedRoles = new SavedAssignedRoles() { RoleId = 3, UserId = customerId, AssignedRoleId = 0, Status = true, CreateDate = DateTime.Now }; _savedAssignedRoles.AddAssignedRoles(savedAssignedRoles); TempData["MessageCreateUsers"] = "User Created Successfully"; } } return(RedirectToAction("Index", "Customer")); } else { return(View("Create")); } } catch { throw; } }
public ActionResult <List <Customer> > AddCustomer(Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = _repository.AddCustomer(customer); return(Ok(result)); }
public IHttpActionResult PostCustomer(Customer customer) { if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } int i = Task.Run <int>(async() => await _customer.AddCustomer(customer)).Result; return(Ok(i)); }
public IActionResult Post([FromBody] Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } customerRepository.AddCustomer(customer); return(StatusCode(StatusCodes.Status201Created)); }
public HttpResponseMessage insertCustomer(CustomerBO customer) { int custs = icustomers.AddCustomer(customer); var session = HttpContext.Current.Session; if (session != null) { HttpContext.Current.Session["CustomerID"] = custs; } return(Request.CreateResponse(HttpStatusCode.OK, "inserted successfully")); }
public HttpResponseMessage AddCustomer([FromBody] Customer customer) { Customer addCustomer = new Customer() { Name = customer.Name, Country = customer.Country, DateOfBirth = customer.DateOfBirth }; _customer.AddCustomer(addCustomer); return(new HttpResponseMessage(HttpStatusCode.Created)); }
// [Route("Add")] public IActionResult Post([FromBody] Customer customer) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } customerRepository.AddCustomer(customer); return(StatusCode(StatusCodes.Status201Created)); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public async Task <ActionResult> AddCustomer(long?Id, AddCustomerModel customerModel) { try { if (!ModelState.IsValid) { return(View(customerModel)); } var customerValidModel = CustomerHelper.BindCustomerModel(customerModel); if (customerModel.CustomerId.IsGreaterThenZero()) { long customerId = iCustomer.UpdateCustomer(customerValidModel); if (customerId == RepositoryReturnCode.MailExist.GetHashCode()) { TempData[MessageConstant.ErrorMessage] = MessageConstant.CustomerEmailError; return(View(customerModel)); } else if (customerId.IsGreaterThenZero()) { TempData[MessageConstant.SuccessMessage] = MessageConstant.CustomerUpdated; } } else { long customerId = iCustomer.AddCustomer(customerValidModel); if (customerId == RepositoryReturnCode.MailExist.GetHashCode()) { TempData[MessageConstant.ErrorMessage] = MessageConstant.CustomerEmailError; return(View(customerModel)); } else if (customerId.IsGreaterThenZero()) { TempData[MessageConstant.SuccessMessage] = MessageConstant.CustomerAdded; } } return(RedirectToAction("Index")); } catch (Exception ex) { LogHelper.ExceptionLog(ex.Message + Constants.ExceptionSeprator + ex.StackTrace); throw ex; } }
public IActionResult Create(CustomersDto customers, bool res) { try { _logger.LogInformation("اجرای متد Create کاستومر"); _customer.AddCustomer(customers, res); if (res == false) { _logger.LogError("موبایل تکراری است"); return BadRequest("Mobile is Duplicate"); } _logger.LogInformation("کاربر ایجاد شد"); return RedirectToAction("Index"); } catch (Exception) { throw; } }
private void createCostumer_Click(object sender, EventArgs e)//checks if every input is valid and no field is empty and creates new customer if everything is correct { if (string.IsNullOrWhiteSpace(firstNameTextbox.Text) == false && string.IsNullOrWhiteSpace(lastNameTextbox.Text) == false && NC.CheckEMail(eMailAdressTextbox.Text) && NC.CheckNumber(balanceTextbox.Text) && string.IsNullOrWhiteSpace(streetNameTextbox.Text) == false && string.IsNullOrWhiteSpace(houseNumberTextbox.Text) == false && string.IsNullOrWhiteSpace(postCodeTextbox.Text) == false && string.IsNullOrWhiteSpace(townTextbox.Text) == false) { if (NCostumer.CheckUnique(eMailAdressTextbox.Text)) { NCostumer.AddCustomer(firstNameTextbox.Text, lastNameTextbox.Text, eMailAdressTextbox.Text, balanceTextbox.Text, streetNameTextbox.Text, houseNumberTextbox.Text, postCodeTextbox.Text, townTextbox.Text); this.Close(); } else { MessageBox.Show("E-Mail address is already used"); } } else { MessageBox.Show("Please enter all fields correctly"); } }
private void shipperSignUpButtom_Click(object sender, EventArgs e) { if (textBox3.Text.Length == 0 || textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox6.Text.Length == 0) { MessageBox.Show("Invalid data"); } else { CustomerDTO user = new CustomerDTO { EMail = textBox3.Text, Addres = textBox4.Text, Phone = textBox5.Text, Description = textBox6.Text }; _customer.AddCustomer(user); var customerMenu = new customerMenuForm(_customer, user.CustomerID); customerMenu.Show(); this.Hide(); } }
public Task <ServiceResponse <Customer> > AddCustomer(Customer customer) { return(_customer.AddCustomer(customer)); }
public IActionResult GetCustomers(Customer customer) { _customer.AddCustomer(customer); return(Created(HttpContext.Request.Scheme + "://" + HttpContext.Request.Host + HttpContext.Request.Path + "/" + customer.Id, customer)); }
public string AddCustomer(Customers customer) { return(_ICustomer.AddCustomer(customer)); }
public void Post([FromBody] string value) { _customerBLL.AddCustomer(value); }
public async Task <IActionResult> OnPostAsync() { int customerID = await customer.AddCustomer(new Customer() { Adress = cars.CustomerAdress, IdPhoto = await Uplode(cars.CustomerIdPhoto, "Customers"), Name = cars.CustomerName, Phone = cars.CustomerPhone }); int incomeID = await income.AddIncome(new Income() { Price = cars.PriceIncome }); if (cars.CheckAmount.Count > 0) { for (int i = 0; i < cars.CheckAmount.Count; i++) { check.AddCheck(new Check() { Amount = cars.CheckAmount[i], DueDate = cars.DueDate[i], IncomeId = incomeID, Name = cars.CheckOwner[i], Photo = await Uplode(cars.CheckPhoto[i], "Check") }); } } await cash.AddCashAsync(new Cash() { Amount = cars.cashTaken, IncomeId = incomeID, Arrested = true }); int saleID = await _sale.Addsale(new Sale() { CarId = cars.carID, Commission = 0, CustomerId = customerID, Date = DateTime.Today, }); var x = car[cars.carID]; x.Sold = true; await car.UpdateCarAsync(x); await sellrecord.AddsellRecords(new SellRecords() { IncomeId = incomeID, SaleId = saleID }); callproc cc = new callproc(); cc.updateCapitalShare(this.User.FindFirst(ClaimTypes.NameIdentifier).Value); cc = null; return(RedirectToAction("Index", "Home")); }
public void AddCustomer(int id, string firstName, string lastName) { Customer customer = new Customer(id, firstName, lastName); customerRepository.AddCustomer(customer); }
public CustomerModel AddCustomer(CustomerModel customerModel) { return(_iCustomer.AddCustomer(customerModel, _apiRequest)); }