public List<Order> getOrdersCustomer(Customer customer)
        {
            List<Order> orders = new List<Order>();

            foreach( DataContractOrder temp in this.orderService.getOrdersCustomer(customer) )
            {
                orders.Add(new Order(temp));
            }

            return orders;
        }
        public bool getLoginUser(Customer customer)
        {
            string body = customer.toXMLLogin();
            XmlDocument xml = this.securityService.loginUser(body);

            if (xml != null && xml.GetElementsByTagName("email").Item(0) != null)
            {
                Handlers.HandlerSession.setUser(xml);
                return true;
            }else
            {
                return false;
            }
        }
        public JsonResult Login()
        {
            if (Request.HttpMethod == "POST")
            {
                String password = Request.Params.Get("password");
                String email = Request.Params.Get("email");

                Customer customer = new Customer(email, password);
                bool response = SecurityFacade.Instance.getLoginUser(customer);
                if (response)
                {
                    return Json(new { success = true, url = Url.Action("Index", "Home") });
                }
                else
                {
                    return Json(new { success = false, message =  Message.ACCESS_DENIED });
                }
            }
            return Json(new { success = false, message = Message.METHOD_DENIED });
        }
        public static Customer getCustomer()
        {
            Customer user = null;
            if (HttpContext.Current.Session["Id"] != null)
            {
                Customer customer = new Customer(HttpContext.Current.Session["Id"].ToString(),
                                          HttpContext.Current.Session["email"].ToString(),
                                          HttpContext.Current.Session["creditcard_number"].ToString(),
                                          HttpContext.Current.Session["creditcard_type"].ToString(),
                                          HttpContext.Current.Session["first_name"].ToString(),
                                          HttpContext.Current.Session["last_name"].ToString(),
                                          HttpContext.Current.Session["type"].ToString(),
                                          HttpContext.Current.Session["doc_type"].ToString()
                                          );
                return customer;
            }
            else
            {
                user = new Customer(0, "anonymous");
            }

            return user;
        }
        public List<DataContractOrder> getOrdersCustomer(Customer customer)
        {
            StringBuilder builder = new StringBuilder(HandlerResource.getServiceAgentLocation("getOrdersCustomer"));
            builder.Append("typeDocument=");
            builder.Append(customer.Document_type);
            builder.Append("&");
            builder.Append("numberDocument=");
            builder.Append(customer.UserID);

            HandlerRequest request = new HandlerRequest();
            String response = request.doRequest(builder.ToString(), "GET");

            try
            {
                List<DataContractOrder> contract = JsonConvert.DeserializeObject<List<DataContractOrder>>((response)) as List<DataContractOrder>;
                return contract;
            }
            catch (JsonSerializationException exception)
            {
                throw (exception);
                // return new Campaign();
            }
        }
Ejemplo n.º 6
0
        public void buildMenu(Customer customer, string controller_actual, string action_actual)
        {
            this.items = new List<ItemMenu>();

            this.addMenu(controller_actual, action_actual, "Home", "Home", "Index", "", null, "icon-home");
            this.addMenu(controller_actual, action_actual, "Quienes Somos?", "Home", "Quienes", "", null, "icon-briefcase");
            this.addMenu(controller_actual, action_actual, "Producto", "Product", "Index", "", null, "icon-shopping_basket");

            if (customer.UserID != 0)
            {
                this.addMenu(controller_actual, action_actual, "Tus ordenes", "Order", "Index", "", null, "icon-receipt");
            }

            this.addMenu(controller_actual, action_actual, "Cart", "ShoppingCart", "Show", "", null, "icon-shopping_cart");

            if(customer.UserID == 0)
            {
                this.addMenu(controller_actual, action_actual, "Iniciar Sesion", "Home", "Login", "", new { id = "login", title = "Iniciar Sesion", href = "#" }, "icon-account_circle");
            }
            else
            {
                this.addMenu(controller_actual, action_actual, String.Concat("Cerrar Sesion (", customer.Email, ")"), "security", "logout", "", null, "icon-account_circle");
            }
        }
 public Customer getCustomer(Customer customer)
 {
     Random rnd = new Random();
     customer.UserID = rnd.Next(1, 500);
     return customer;
 }