Exemplo n.º 1
0
        public ActionResult MyProfileEdit(UserVM user, SkillsVM skillVM, HttpPostedFileBase Image, string WebcamImage)
        {
            if (WebcamImage != "null" && WebcamImage != string.Empty)
            {
                var path = HttpContext.Server.MapPath("~/WebImages/" + WebcamImage + ".jpg");
                user.Avatar = System.IO.File.ReadAllBytes(path);
            }

            if (Image != null && !IsImage(Image))
            {
                return Json(new { result = "Error", message = "Wrong image" });
            }
            if (ModelState.IsValid)
            {

                if (Image != null)
                {
                    using (var binaryReader = new BinaryReader(Image.InputStream))
                    {
                        user.Avatar = binaryReader.ReadBytes(Image.ContentLength);
                    }
                }

                var model = new UserVM(User, user, skillVM);
                System.IO.File.Delete(HttpContext.Server.MapPath("~/WebImages/" + WebcamImage + ".jpg"));
                model.SaveChanges();
                return Json(new { result = "Redirect", url = "/" + model.User.Login });
            }
            else
            {
                return Json(new { result = "Error", message = ModelState.Values.SelectMany(v => v.Errors).FirstOrDefault().ErrorMessage });
            }
        }
Exemplo n.º 2
0
        public ActionResult SkillsEdit()
        {
            var skillsVM = new SkillsVM(User);


            return PartialView("SkillsEdit", skillsVM);
        }
Exemplo n.º 3
0
 public ActionResult Skills(string Login)
 {
     var skillVM = new SkillsVM(Login);
     return PartialView(skillVM.UserSkills);
 }
Exemplo n.º 4
0
 public UserVM(IPrincipal user, UserVM editedUser, SkillsVM skill) : this(user)
 {
     _editedUser = editedUser;
     _editedSkills = skill;
 }