Exemplo n.º 1
0
        public async Task <ActionResult> UpdateDetails(CustomerInformationModel model)
        {
            HttpCookie WeedHackSesh    = System.Web.HttpContext.Current.Request.Cookies["WeedHackersSession"];
            var        UserDetails     = MvcApplication.Sessions[WeedHackSesh.Value].User;
            var        CustomerDetails = WeedHackersContext.Customers.ToList().Find(u => u.Id == UserDetails.Id);

            if (ModelState.IsValid)
            {
                var cryptionHelper = new FrostAura.Dynamics.Core.Helpers.FaCryptographyHelper();
                UserDetails.Email = model.email;
                if (model.password == "")
                {
                    UserDetails.Password = UserDetails.Password;
                }
                UserDetails.Password    = cryptionHelper.HashString(model.password);
                UserDetails.PhoneNumber = model.phonenumber;
                CustomerDetails.Address = model.Address;

                WeedHackersContext.Users.AddOrUpdate(u => u.Id, UserDetails);
                WeedHackersContext.Customers.AddOrUpdate(c => c.Id, CustomerDetails);

                await WeedHackersContext.SaveChangesAsync();

                FlashMessage.Confirmation("Profile Information", "Your information has been updated.");
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("Email", "Could not update details!");
            FlashMessage.Danger("Update Unsuccessful", "We could not update your profile. Please ensure you have filled out your new details correctly and try again.");
            return(View("CustomerProfile", model));
            //===============================================================
        }
Exemplo n.º 2
0
        // GET: Customer
        public ActionResult Index()
        {
            var WeedHackSesh = System.Web.HttpContext.Current.Request.Cookies["WeedHackersSession"].Value;
            var sessionModel = MvcApplication.Sessions[WeedHackSesh];
            var model        = new CustomerInformationModel();

            model.CurrentCustUser = sessionModel.User;

            model.ServiceRequestModel          = new ServiceRequestModel();
            model.ServiceRequestModel.Services = WeedHackersContext.Services.ToList();
            model.Address = sessionModel.User.Customer.Address;



            //model.CurrentCustomer =
            //    WeedHackersContext.Customers.ToList().Find(u => u.UserId == model.CurrentCustUser.Id);
            //model.CurreCustomerType =
            //    WeedHackersContext.CustomerTypes.ToList().Find(ct => ct.Id == model.CurrentCustomer.CustomerTypeId);
            #region NavigationsForCustomer
            model.SideNavModels.Add(new NavigationModel
            {
                Link  = Url.Action("CustomerProfile", "Customer"),
                Title = "Profile Information",
                Icon  = "fa fa-user-circle-o",
                Class = ""
            });
            model.SideNavModels.Add(new NavigationModel
            {
                Link  = Url.Action("Index", "Customer"),
                Title = "New Service Request",
                Icon  = "fa fa-plus",
                Class = "active"
            });
            model.SideNavModels.Add(new NavigationModel
            {
                Link  = Url.Action("QuotesReceived", "Customer"),
                Title = "View Quotes",
                Icon  = "fa fa-plus",
                Class = ""
            });
            model.SideNavModels.Add(new NavigationModel
            {
                Link  = Url.Action("Logout", "Security"),
                Icon  = "fa fa-sign-out",
                Title = "Sign Out"
            });

            #endregion

            return(View(model));
        }
        public IHttpActionResult Postemp_CustomerInformation(CustomerInformationModel dto)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}
            var result = customerInformationService.Save(dto, dto.Id);

            if (result == null)
            {
                return(NotFound());
            }

            return(Ok(result));
        }
        public IHttpActionResult Postemp_SubSiteCustomerInformation(CustomerInformationModel dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            int result = customerInformationService.SaveCustomerSubSiteInfo(dto, dto.Id);

            if (result == 0)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
Exemplo n.º 5
0
        public async Task <ActionResult> CustomerProfile()
        {
            var WeedHackSesh = System.Web.HttpContext.Current.Request.Cookies["WeedHackersSession"].Value;
            var model        = new CustomerInformationModel();
            var sessionModel = MvcApplication.Sessions[WeedHackSesh];

            model.CurrentCustUser = sessionModel.User;
            model.CurrentCustomer = sessionModel.User.Customer;
            model.CurrentCustomer.CustomerType = WeedHackersContext.CustomerTypes.Single(c => c.Id == sessionModel.User.Customer.CustomerTypeId);

            #region NavigationsForCustomer
            model.SideNavModels.Add(new NavigationModel
            {
                Link  = Url.Action("CustomerProfile", "Customer"),
                Title = "Profile Information",
                Icon  = "fa fa-user-circle-o",
                Class = "active"
            });
            model.SideNavModels.Add(new NavigationModel
            {
                Link  = Url.Action("Index", "Customer"),
                Title = "New Request Service",
                Icon  = "fa fa-plus",
                Class = ""
            });
            model.SideNavModels.Add(new NavigationModel
            {
                Link  = Url.Action("QuotesReceived", "Customer"),
                Title = "View Quotes",
                Icon  = "fa fa-file-text",
                Class = ""
            });
            model.SideNavModels.Add(new NavigationModel
            {
                Link  = Url.Action("Logout", "Security"),
                Icon  = "fa fa-sign-out",
                Title = "Sign Out"
            });

            #endregion


            return(View(model));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> RequestService(CustomerInformationModel model)
        {
            var WeedHackSesh    = System.Web.HttpContext.Current.Request.Cookies["WeedHackersSession"].Value;
            var UserDetails     = MvcApplication.Sessions[WeedHackSesh].User;
            var CustomerDetails = WeedHackersContext.Customers.ToList().Find(u => u.Id == UserDetails.Id);
            ServiceRequestStatusUpdate ServiceRequestStatus;

            CustomerDetails.Address = model.Address;

            WeedHackersContext.Customers.AddOrUpdate(c => c.Id, CustomerDetails);

            if (ModelState.IsValid)
            {
                model.ServiceRequestModel.ServiceRequest.CustomerId = CustomerDetails.Id;

                WeedHackersContext.ServiceRequests.Add(model.ServiceRequestModel.ServiceRequest);
                ServiceRequestStatus = new ServiceRequestStatusUpdate
                {
                    ServiceRequestId = model.ServiceRequestModel.ServiceRequest.Id,
                    ServiceStatusId  = WeedHackersContext.ServiceStatuses.Single(s => s.Name == "Created").Id,
                    Message          = "Service Requested has been created",
                };
                WeedHackersContext.ServiceRequestStatusUpdates.Add(ServiceRequestStatus);
                // Magic
                WeedHackers_Data.Entities.Service service =
                    WeedHackersContext
                    .Services
                    .Single(s => s.Id == model.ServiceRequestModel.ServiceRequest.ServiceId);

                var assigningEmployee = WeedHackersContext
                                        .Employees
                                        .Include(e => e.EmployeeType)
                                        .Where(e => e.DepartmentId == service.DepartmentId && e.EmployeeType.Name == "Service Advisor")
                                        .Include(e => e.AssignedServiceRequests)
                                        .OrderByDescending(e => e.AssignedServiceRequests.Count)
                                        .First();

                model.ServiceRequestModel.ServiceRequest.ServiceAdvisorId = assigningEmployee.Id;

                await WeedHackersContext.SaveChangesAsync();
            }
            FlashMessage.Confirmation("Service Requested", "Your service has successfully been requested and is awaiting inspection.");
            return(RedirectToAction("Index", "Customer"));
        }