Ejemplo n.º 1
0
        public ActionResult ChangeInfo(FinishSetupViewModel model)
        {
            var repo = new DapperRepository();

            if (model.Interests != null)
            {
                var tokens = model.Interests.Split(',');
                repo.SetInterests(repo.GetCurrentUser(), tokens);
            }
            repo.setProfileInfo(model);
            return(RedirectToAction("Index", "Manage"));
        }
Ejemplo n.º 2
0
        public ActionResult FinishSetup(HttpPostedFileBase file, FinishSetupViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            char?  gender    = model.Gender;
            int?   cityId    = model.CityId;
            string interests = model.Interests;

            DapperRepository repo        = new DapperRepository();
            ApplicationUser  CurrentUser = repo.GetCurrentUser();

            if (CurrentUser.SetupCompleted)
            {
                return(HttpNotFound());
            }

            string SavePath   = null;
            string ImgRelPath = null;

            string[] tokens = null;
            if (file != null)
            {
                string pic = CurrentUser.Id + System.IO.Path.GetExtension(file.FileName);
                Debug.WriteLine(pic);
                SavePath = System.IO.Path.Combine(
                    Server.MapPath("~/images/a"), pic);
                // file is uploaded
                file.SaveAs(SavePath);
                //Conversion to jpg( throws exceptions)
                if (!System.IO.Path.GetExtension(file.FileName).Equals(".jpg"))
                {
                    System.Drawing.Image image = System.Drawing.Image.FromFile(SavePath);
                    SavePath = System.IO.Path.Combine(Server.MapPath("~/images/a"), CurrentUser.Id + ".jpg");
                    System.IO.File.Delete(SavePath);
                    image.Save(SavePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                }
                ImgRelPath = "/images/a/" + CurrentUser.Id + ".jpg";
                //Debug.WriteLine(path);
            }

            /*if (gender != null)
             * {
             *  Debug.WriteLine("Gender:" + gender);
             * }
             * if (cityId != null)
             * {
             *  Debug.WriteLine("CityId:" + cityId);
             * }*/
            if (interests != null)
            {
                tokens = interests.Split(',');
                repo.SetInterests(CurrentUser, tokens);
                //Debug:

                /*foreach (var item in tokens)
                 * {
                 *  Debug.WriteLine("Interest:" + item.ToLower());
                 * }
                 * Debug.WriteLine("Interests:" + interests);*/
            }
            repo.FinishSetup(CurrentUser, ImgRelPath, gender, cityId);
            return(RedirectToAction("Index", "Chat"));
        }