public IActionResult Edit(int id, CustomerFormModel model) { if (!ModelState.IsValid) { return(this.View(model)); } var customerExists = this.customers.Exists(id); if (!customerExists) { return(NotFound()); } this.customers.Edit ( id, model.Name, model.BirthDay, model.IsYoungDriver ); return(RedirectToAction(nameof(All), new { order = OrderDirection.Ascending })); }
// GET: AdminsArea/Customer/Create public ActionResult Create() { IEnumerable <Dealer> dealers; using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://localhost:44318/Dealer/"); //HTTP GET var responseTask = client.GetAsync("Get"); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <IEnumerable <Dealer> >(); readTask.Wait(); dealers = readTask.Result; } else { dealers = Enumerable.Empty <Dealer>(); } } CustomerFormModel entity = new CustomerFormModel { dealers = dealers, customer = new Customer() }; return(PartialView(entity)); }
public ActionResult Save(Customer customer) { if (!ModelState.IsValid) { var viewModel = new CustomerFormModel { Customer = customer, MembershipTypes = _context.MembershipTypes.ToList() }; return(View("CustomerForm", viewModel)); } if (customer.Id == 0) { _context.Customers.Add(customer); } else { var customerInDb = _context.Customers.Single(c => c.Id == customer.Id); customerInDb.Name = customer.Name; customerInDb.DOB = customer.DOB; customerInDb.MembershipTypeId = customer.MembershipTypeId; customerInDb.IsSubscribedToNewsletter = customer.IsSubscribedToNewsletter; } _context.SaveChanges(); return(RedirectToAction("Index", "Customers")); }
public ActionResult New() { var memeberShipType = _context.membershipTypes.ToList(); var customerFormModel = new CustomerFormModel { membershipTypes = memeberShipType }; return(View(customerFormModel)); }
public IActionResult Create(CustomerFormModel model) { if (!ModelState.IsValid) { return(View(model)); } this.customers.Create(model.Name, model.Birthdate, model.IsYoungDriver); return(RedirectToAction(nameof(All), new { order = OrderType.Ascending.ToString() })); }
public IActionResult Create(CustomerFormModel formModel) { if (!ModelState.IsValid) { return(View(formModel)); } this.customers.Create(formModel.Name, formModel.BirthDate, formModel.IsYoungDriver); return(RedirectToAction(nameof(All), new { order = OrderDirection.Ascending })); }
public IActionResult Create(CustomerFormModel model) { if (!ModelState.IsValid) { return(View(model)); } this.customers.Create(model.Name, model.Birthday, model.IsYoungDriver); return(RedirectToAction(nameof(All))); }
public IActionResult Create(CustomerFormModel model) { if (!ModelState.IsValid) { return(View(model)); } this.customers.Create(model.Name, model.Birthday, model.IsYoungDriver); //new { order = OrderDirection.Ascending.ToString() }) - this is because the action All requires string order return(RedirectToAction(nameof(All), new { order = OrderDirection.Ascending.ToString() })); }
public IActionResult Create(CustomerFormModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } this.customers .Create(model.Name, model.BirthDay, model.IsYoungDriver); return(this.RedirectToAction(nameof(this.All), new { order = OrderDirection.Ascending })); }
public ActionResult Index(CustomerFormModel cfm, FormCollection frm) //public ActionResult Index(string fname, string bintwo, string binone, string jobtype) { String jt = frm["jobtype"].ToString(); String del = frm["delivery"].ToString(); String pickup = frm["pickup"].ToString(); cfm.address.Country = "Canada"; db.Customers.Add(cfm.customer); db.Addresses.Add(cfm.address); Customer c = db.Customers.Find(cfm.customer.ID); Address a = db.Addresses.Find(cfm.address.ID); c.Addresses.Add(a); var queryBin = (from b in db.Bins where b.Status == "Available" select b).ToList(); if (queryBin.Count > 0) { Bin bin = queryBin.First(); cfm.orders.Bin = bin; cfm.orders.SourceOfOrdering = "Online"; cfm.orders.JobType = jt; cfm.orders.DeliveryDateTime = DateTime.Parse(del); cfm.orders.PickupDateTime = DateTime.Parse(pickup); db.Orders.Add(cfm.orders); Order o = db.Orders.Find(cfm.orders.ID); c.Orders.Add(o); cfm.orders.Status = "New"; bin.Status = "Booked"; db.SaveChanges(); return(RedirectToAction("Confirm")); } ViewBag.Message = "Sorry, We are out of Bins at moment"; return(View("Index")); // return RedirectToAction("Confirmation"); //return Content($"Hello {fname} {jobtype} {bintwo} {binone}"); //return View(); }
public ActionResult New() { var membershipTypes = _context.MembershipTypes.ToList(); var viewModel = new CustomerFormModel { MembershipTypes = membershipTypes, Customer = new Customer() }; return(View("CustomerForm", viewModel)); }
public IActionResult Add(CustomerFormModel model) { if (!ModelState.IsValid) { return(View(model)); } this.customerService.Add( model.Name, model.BirthDate, model.IsYoungDriver); return(RedirectToAction(nameof(All))); }
public ActionResult Create(CustomerFormModel form) { if (ModelState.IsValid) { //maps to domain object from view model var command = Mapper.Map <CustomerFormModel, NewCustomerCommand>(form); var message = new BrokeredMessage(command); // Send customer message to Service Bus Queue ServiceBusQueueHelper.CustomersQueueClient.Send(message); return(RedirectToAction("Index")); } return(View(form)); }
public IActionResult Create(CustomerFormModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } this.customers .Create(model.Name, model.BirthDay, model.IsYoungDriver); this.logs.Create(this.User.Identity.Name, MethodBase.GetCurrentMethod().Name, ModelType); return(this.RedirectToAction(nameof(this.All), new { order = OrderDirection.Ascending })); }
public IActionResult Create(CustomerFormModel customerModel) { if (!ModelState.IsValid) { return(View(customerModel)); } customers.Create( customerModel.Name, customerModel.BirthDate, customerModel.IsYoungDriver ); return(RedirectToAction(nameof(All), new { order = "ascending" })); }
public ActionResult GetCustomer(int id) { //var found = false; var _customer = _context.customers.Include(c => c.membershipType).SingleOrDefault(item => item.Id == id); if (_customer != null) { var membershipType = _context.membershipTypes.ToList(); var customerFormModel = new CustomerFormModel { customer = _customer, membershipTypes = membershipType }; return(View("New", customerFormModel)); } return(HttpNotFound()); }
public ActionResult Edit(int id) { var customer = _context.Customers.SingleOrDefault(c => c.Id == id); if (customer == null) { return(HttpNotFound()); } var viewModel = new CustomerFormModel { Customer = customer, MembershipTypes = _context.MembershipTypes.ToList() }; return(View("CustomerForm", viewModel)); }
public IActionResult Edit(int id, CustomerFormModel model) { if (!ModelState.IsValid) { return(View(model)); } if (!this.customerService.IsCustomerExisting(id)) { return(NotFound()); } this.customerService.Edit(id, model.Name, model.BirthDate, model.IsYoungDriver); return(RedirectToAction(nameof(All), new { order = OrderDirection.Ascending })); }
public IActionResult Delete(int id, CustomerFormModel model) { if (!this.customerService.Exists(id)) { return(this.RedirectToAction(nameof(All))); } try { this.customerService.Remove(id); return(this.RedirectToAction(nameof(All))); } catch (Exception) { return(this.View(CustomerFormView, model)); } }
public IActionResult Create(CustomerFormModel model) { if (!this.ModelState.IsValid) { return(this.View(CustomerFormView, model)); } try { this.customerService.Create(model.Name, model.BirthDate, model.IsYoungDriver); return(this.RedirectToAction(nameof(All))); } catch (Exception) { return(this.View(CustomerFormView, model)); } }
public IActionResult Edit(int id) { CustomerServiceModel customer = this.customerService.GetCustomerById(id); if (customer == null) { return(NotFound()); } CustomerFormModel model = new CustomerFormModel { Name = customer.Name, BirthDate = customer.BirthDate, IsYoungDriver = customer.IsYoungDriver }; return(View(model)); }
public ActionResult Register(CustomerFormModel newCustomer) { CustomerContainer customer = new CustomerContainer(); Customer c = new Customer() { FirstName = newCustomer.FirstName, LastName = newCustomer.LastName, EmailAddress = newCustomer.EmailAddress, Password = newCustomer.Password, PhoneNumber = newCustomer.PhoneNumber, isActive = "true" }; customer.Customers.Add(c); customer.SaveChanges(); return(RedirectToAction("RegisterForwardPage")); }
public IActionResult Edit(int id) { var customerModel = this.customerService.GetById(id); if (customerModel == null) { return(NotFound()); } var customerFormModel = new CustomerFormModel { Name = customerModel.Name, BirthDate = customerModel.BirthDate, IsYoungDriver = customerModel.IsYoungDriver }; return(View(customerFormModel)); }
public IActionResult Edit(int id, CustomerFormModel customerModel) { var customerExists = customers.Exists(id); if (!customerExists) { return(RedirectToAction(nameof(All), new { order = "ascending" })); } if (!ModelState.IsValid) { return(View(customerModel)); } customers.Edit(customerModel.Id, customerModel.Name, customerModel.BirthDate, customerModel.IsYoungDriver); return(RedirectToAction(nameof(All), new { order = "ascending" })); }
public IActionResult Edit(int id, CustomerFormModel model) { if (!ModelState.IsValid) { return(View(model)); } bool customerExist = this.customerService.Exists(id); if (!customerExist) { return(NotFound()); } this.customerService.Edit(id, model.Name, model.BirthDate, model.IsYoungDriver); return(this.RedirectToAction(nameof(All))); }
public IActionResult Edit(int id, CustomerFormModel model) { if (!ModelState.IsValid) { return(View(model)); } bool customerExists = this.customers.Exists(id); if (!customerExists) { return(NotFound()); } this.customers.Edit(id, model.Name, model.Birthday, model.IsYoungDriver); //new { order = OrderDirection.Ascending.ToString() }) - this is because the action All requires string order return(RedirectToAction(nameof(All), new { order = OrderDirection.Ascending.ToString() })); }
public IActionResult Edit(int id) { var custmerExists = this.customerService.Exists(id); if (!custmerExists) { return(RedirectToAction(nameof(All))); } var customer = this.customerService.GetById(id); var model = new CustomerFormModel { Name = customer.Name, BirthDate = customer.BirthDate, IsYoungDriver = customer.IsYoungDriver }; return(this.View(model)); }
public IActionResult Edit(int id) { var customerExists = customers.Exists(id); if (!customerExists) { return(RedirectToAction(nameof(All), new { order = "ascending" })); } var customer = this.customers.ById(id); var vm = new CustomerFormModel() { Id = customer.Id, Name = customer.Name, BirthDate = customer.BirthDate, IsYoungDriver = customer.IsYoungDriver }; return(View(vm)); }
// GET: AdminsArea/Customer/Edit/5 public ActionResult Edit(int id) { IEnumerable <Dealer> dealers; Customer customer = new Customer(); using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://localhost:44318/"); //HTTP GET var responseTask = client.GetAsync("Dealer/Get"); var responseTask2 = client.GetAsync("Customer/Get/" + id); responseTask.Wait(); responseTask2.Wait(); var result = responseTask.Result; var result2 = responseTask2.Result; if (result.IsSuccessStatusCode && result2.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <IEnumerable <Dealer> >(); readTask.Wait(); dealers = readTask.Result; var readTask2 = result2.Content.ReadAsAsync <Customer>(); readTask2.Wait(); customer = readTask2.Result; } else { dealers = Enumerable.Empty <Dealer>(); customer = null; ModelState.AddModelError(string.Empty, "Server error occured while retriving data"); } } CustomerFormModel entity = new CustomerFormModel { dealers = dealers, customer = customer }; return(PartialView(entity)); }
public IActionResult Edit(int id, CustomerFormModel model) { if (!this.customerService.Exists(id)) { return(this.RedirectToAction(nameof(All))); } if (!this.ModelState.IsValid) { return(this.View(CustomerFormView, model)); } try { this.customerService.Update(id, model.Name, model.BirthDate); return(this.RedirectToAction(nameof(All))); } catch (Exception) { return(this.View(CustomerFormView, model)); } }