Esempio n. 1
0
        public ActionResult Edit(string id)
        {
            if (User.Identity.IsAuthenticated && ((User.IsInRole("User") && id == User.Identity.GetUserId()) || User.IsInRole("Admin")))
            {
                try
                {
                    SiteUser siteUser = SiteUserManager.GetSiteUserById(id);
                    string   picture;
                    string   phoneNumber = siteUser.ApplicationUser.PhoneNumber.Substring(4);
                    try
                    {
                        string PictureUID = SiteUserManager.GetPictureUIDById(id);
                        if (PictureUID == null)
                        {
                            throw new Exception();
                        }
                        picture = "/Images/Uploaded/Source/" + PictureUID;
                    }
                    catch (Exception)
                    {
                        picture = null;
                    }

                    return(View(new EditUserViewModel {
                        PictureName = picture, Surname = siteUser.Surname, Name = siteUser.Name, FathersName = siteUser.FathersName, Email = siteUser.ApplicationUser.Email, PhoneNumber = phoneNumber, DateOfBirth = siteUser.DateOfBirth
                    }));
                }
                catch (Exception)
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 2
0
 public ActionResult UserProfile(string id)
 {
     if (User.Identity.IsAuthenticated)
     {
         try
         {
             SiteUser siteUser = SiteUserManager.GetSiteUserById(id);
             if (siteUser == null)
             {
                 throw new Exception();
             }
             ViewBag.PhoneNumber = siteUser.ApplicationUser.PhoneNumber.Substring(4);
             try
             {
                 string PictureUID = SiteUserManager.GetPictureUIDById(id);
                 if (PictureUID == null)
                 {
                     throw new Exception();
                 }
                 ViewBag.Picture = "/Images/Uploaded/Source/" + PictureUID;
             }
             catch (Exception)
             {
                 ViewBag.Picture = "/Images/Default/anonym.png";
             }
             return(View(siteUser));
         }
         catch (Exception)
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     return(RedirectToAction("Index", "Home"));
 }