public ActionResult Contact(string message) { if (string.IsNullOrEmpty(message) || message.Length < 20) { ModelState.AddModelError("message", "Too short feedback"); } if (ModelState.IsValid) { var userId = User.Identity.GetUserId(); var customer = _customerService.GetCustomerByIdentityUserId(userId); var cistomerViewModel = MappingViewModel.MapCustomerViewModel(customer); var feedback = new FeedbackViewModel() { Customer = cistomerViewModel, CustomerId = cistomerViewModel.Id, IsRead = false, Message = message, Date = DateTime.Now }; var feedbackDto = MappingViewModel.MapFeedbackDTO(feedback); _customerService.SendFeedback(feedbackDto); SLogger.InfoToFile($"Customer {customer.Id} sent feedback"); var messageInfo = new MessageViewModel() { Status = "success", Info = "Your feedback has been sent" }; return(RedirectToAction("Index", "Customer", messageInfo)); } return(View()); }
public ActionResult PersonalArea() { var userId = User.Identity.GetUserId(); var tours = _customerService.GetTourCustomerByCustomerId(userId); var customer = _customerService.GetCustomerByIdentityUserId(userId); var cistomerViewModel = MappingViewModel.MapCustomerViewModel(customer); var toursViewModel = MappingViewModel.MapTourCustomerListViewModel(tours); ViewBag.Customer = cistomerViewModel; return(View(toursViewModel)); }
public ActionResult ChangeInformation(string name, string surname) { var userId = User.Identity.GetUserId(); var customer = _customerService.GetCustomerByIdentityUserId(userId); var cistomerViewModel = MappingViewModel.MapCustomerViewModel(customer); if (Request.HttpMethod == "POST") { if (name.Length <= 3) { ModelState.AddModelError("name", "Please enter valid name"); } if (surname.Length <= 3) { ModelState.AddModelError("surname", "Please enter valid surname"); } if (ModelState.IsValid) { customer.Name = name; customer.Surname = surname; _customerService.ChangePersonalInformation(customer); SLogger.InfoToFile($"Customer {customer.Id} changed name to {name} {surname}"); var messageInfo = new MessageViewModel() { Status = "success", Info = "Changed information" }; return(RedirectToAction("Index", messageInfo)); } else { return(View(cistomerViewModel)); } } else { return(View(cistomerViewModel)); } }
public ActionResult ChangeDiscount(int id, int?maxDiscount, int?stepDiscount) { var customer = _managerService.GetCustomerById(id); var customerViewModel = MappingViewModel.MapCustomerViewModel(customer); if (Request.HttpMethod == "POST") { if (maxDiscount == null) { ModelState.AddModelError("maxDiscount", "Please enter max discount"); } if (stepDiscount == null) { ModelState.AddModelError("stepDiscount", "Please enter step discount"); } if (ModelState.IsValid) { customer.StepDiscount = stepDiscount.Value; customer.MaxDiscount = maxDiscount.Value; _managerService.ChangeDiscountCustomer(customer); SLogger.InfoToFile($"Manager change discount customer id: {customer.Id}"); var messageInfo = new MessageViewModel() { Status = "success", Info = $"Changed discount for {customer.Name}" }; return(RedirectToAction("Index", messageInfo)); } else { return(View(customerViewModel)); } } else { return(View(customerViewModel)); } }