Esempio n. 1
0
        public ActionResult Login(string email = null, string password = null)
        {
            if (Session["success-message"] != null)
            {
                ViewData.AddSafe("success-message", Session["success-message"]);
                Session.Remove("success-message");
            }
            if (Session["error-message"] != null)
            {
                ViewData.AddSafe("error-message", Session["error-message"]);
                Session.Remove("error-message");
            } //<--- this code sucks ... lol

            if (!String.IsNullOrEmpty(email) && !String.IsNullOrEmpty(password))
            {
                if (!email.ToLower().EndsWith("wakanow.com"))
                {
                    ViewData.AddSafe("error-message", "Email must be in the Wakanow Domain");
                    return(View());
                }
                if (Models.User.Validate(email, password))
                {
                    Site.Context().Session.AddSafe("json-edit-validated", true);
                    Models.User currentUser = (Models.User)Session["json-site-user"];
                    if (currentUser.IsRole("customer-feedback"))
                    {
                        return(this.Redirect("~/customerfeedback/admin"));
                    }
                    return(this.Redirect("~/edit"));
                }
                ViewData.AddSafe("error-message", "Invalid Email or Password");
            }
            return(View());
        }
Esempio n. 2
0
 public ActionResult Add(string Title = null, string Category = null, string Description = null, string ResizeForDevices = null, HttpPostedFileBase Data = null)
 {
     if (Data != null)
     {
         Image temp = Models.Image.AddTemp(Data.InputStream.ToBytes(), Data.FileName.Split('.').Last());
         Session.AddSafe("sessionTempImage", temp);
         ViewData.AddSafe("viewTempImage", temp);
     }
     if (!String.IsNullOrEmpty(Title))
     {
         var sessionImage = (Models.Image)Session["sessionTempImage"];
         if (sessionImage != null)
         {
             sessionImage.Title            = Title;
             sessionImage.Description      = Description;
             sessionImage.Category         = Category;
             sessionImage.ResizeForDevices = (ResizeForDevices == "on") ? true : false;
             sessionImage.Active           = true;
             sessionImage.TargetDevice     = Image.Device.GetDefault().ID;
             List <Image> newImages = Image.Add(sessionImage).ToList();
             Session.Remove("sessionTempImage");
             return(Redirect("~/images/" + sessionImage.Name));
         }
     }
     return(View());
 }
Esempio n. 3
0
        public ActionResult EditDevice(string Name = null, string ShortName = null, int Width = 0, int Height = 0, int Orientation = 0, string UserAgent = null, string IsDefault = null)
        {
            string shortName = (string)RouteData.Values["short_name"];

            ViewData.AddSafe("device", Models.Image.Device.GetDevice(shortName));
            if (!String.IsNullOrEmpty(Name) &&
                !String.IsNullOrEmpty(ShortName) &&
                Width > 0 &&
                Height > 0)
            {
                try
                {
                    Models.Image.Device.Edit(new Models.Image.Device()
                    {
                        Name        = Name,
                        Height      = Height,
                        Orientation = (Models.Image.Device.DeviceOrientation)Orientation,
                        ShortName   = ShortName,
                        UserAgent   = UserAgent,
                        Width       = Width,
                        IsDefault   = IsDefault == "on" ? true : false
                    });
                    ViewData.Add("success-message", Name + " Edited Successfully");
                }
                catch (Exception ex)
                {
                    Site.LogError(ex);
                    ViewData.Add("error-message", ex.Message);
                }
            }
            return(View());
        }
Esempio n. 4
0
        public ActionResult DeviceDetails()
        {
            string shortName = (string)RouteData.Values["short_name"];

            ViewData.AddSafe("device", Models.Image.Device.GetDevice(shortName));
            return(View());
        }
Esempio n. 5
0
        public ActionResult Edit(string Name = null, string Title = null, string Category = null, string Description = null, HttpPostedFileBase Data = null)
        {
            if (!String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(Category))
            {
                try
                {
                    var img = Models.Image.GetImage(Name);
                    if (img != null)
                    {
                        img.Title        = Title;
                        img.Description  = Description;
                        img.Category     = Category;
                        img.CreationTime = DateTime.Now;
                    }
                    if (Data != null)
                    {
                        img.Extension = Data.FileName.Split('.').Last();
                        img.Data      = Data.InputStream.ToBytes();
                    }
                    Models.Image.Edit(img);
                    ViewData.AddSafe("success-message", "Image " + Name + " has been updated");
                }
                catch (Exception ex)
                {
                    Site.LogError(ex);
                    ViewData.AddSafe("error-message", ex.Message);
                }
            }

            var fileName = (string)RouteData.Values["filename"];
            var image    = Models.Image.GetImage(fileName);

            if (image == null)
            {
                ViewData.AddSafe("error-message", "Image " + fileName + " Not Found");
                return(Redirect("~/images/"));
            }
            ViewData.AddSafe("image", image);
            if (!String.IsNullOrEmpty(Name))
            {
                return(Redirect("~/images/" + Name));
            }
            return(View());
        }
Esempio n. 6
0
        public ActionResult ChangePassword(string oldPassword = null, string newPassword = null)
        {
            string _redirectUrl = _validateLogin();

            if (!String.IsNullOrEmpty(_redirectUrl))
            {
                return(Redirect(_redirectUrl));
            }
            User currentUser = (User)Session["json-site-user"];

            ViewData.AddSafe("current-user", currentUser);
            if (!String.IsNullOrEmpty(newPassword))
            {
                if (currentUser.IsReset)
                {
                    JsonStore.Mvc.Models.User.changePassword(currentUser.Email, newPassword);
                    ViewData.AddSafe("success-message", "Password Change Successful");
                    currentUser.IsReset = false;
                    Session.AddSafe("json-site-user", currentUser);
                }
                else if (!String.IsNullOrEmpty(oldPassword))
                {
                    if (JsonStore.Mvc.Models.User.Validate(currentUser.Email, oldPassword))
                    {
                        JsonStore.Mvc.Models.User.changePassword(currentUser.Email, newPassword);
                        ViewData.AddSafe("success-message", "Password Change Successful");
                        currentUser.IsReset = false;
                        Session.AddSafe("json-site-user", currentUser);
                    }
                    else
                    {
                        ViewData.AddSafe("error-message", "Invalid Old Password");
                    }
                }
                else
                {
                    ViewData.AddSafe("error-message", "Old Password not specified");
                }
            }
            return(View());
        }