Ejemplo n.º 1
0
 //[ValidateAntiForgeryToken]
 public ActionResult ViewProfile(ViewProfileModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             //if (model.ProfileImage != null && model.ProfileImage.ContentLength > 0)
             //{
             //    if (UploadImage(model.ProfileImage, "/Files/Content/Images/Avatar/", out var profileImagePath))
             //        model.ProfileImagePath = profileImagePath.Replace("/Files/", "");
             //}
             var user = Client.Services.API.Visa.GetUser(model.ID);
             if (user != null)
             {
                 user.Name  = model.Name;
                 user.Email = model.Email;
                 Client.Services.API.Visa.SaveUser(user);
             }
         }
         catch
         {
             // TODO: Handle exceptions and log them.
         }
     }
     return(View(model));
 }
Ejemplo n.º 2
0
 public ActionResult ViewProfile()
 {
     if (Request.Cookies["User"] != null)
     {
         ViewProfileModel vp = new ViewProfileModel();
         userRepo = new RepositoryFactory().Create <User>();
         User user = ((IUserRepository)userRepo).GetByUserName(Request.Cookies["User"]["userName"]);
         if (user != null)
         {
             if (user.Password.Equals(Request.Cookies["User"]["userPassword"]))
             {
                 vp.UserName         = user.UserName;
                 vp.Name             = user.Name;
                 vp.Email            = user.Email;
                 vp.Gender           = user.Gender;
                 vp.Dob              = user.DateOfBirth;
                 vp.Role             = user.Role;
                 vp.Status           = user.Status;
                 vp.RegistrationDate = user.RegistrationDate;
             }
         }
         else
         {
             return(RedirectToAction("InValidAccess", "User"));
         }
         return(View("Profile/ViewProfile", vp));
     }
     else
     {
         return(RedirectToAction("InValidAccess", "User"));
     }
 }
Ejemplo n.º 3
0
        public async Task <IHttpActionResult> GetCurrent()
        {
            var userId      = User.Identity.GetUserId();
            var viewProfile = new ViewProfileModel {
                Profile = await _db.Profiles.SingleOrDefaultAsync(c => c.UserId == userId) ??
                          new Profile
                {
                    UserId = userId
                },

                ManagerTeams = await _db.Teams
                               .Include(team => team.Division)
                               .Include(team => team.Manager)
                               .Where(team => team.Manager.Profile.UserId == userId)
                               .ToListAsync(),

                PlayerTeams = await _db.Players
                              .Include(player => player.Teams.Select(team => team.Division))
                              .Include(player => player.Teams.Select(team => team.Manager))
                              .Where(player => player.Profile.UserId == userId)
                              .SelectMany(player => player.Teams)
                              .ToListAsync()
            };

            return(Ok(viewProfile));
        }
Ejemplo n.º 4
0
        public ActionResult ViewProfile()
        {
            ViewProfileModel Model = new ViewProfileModel();

            Model.SucessMessage = (TempData["Success"] != null ? TempData["Success"].ToString() : string.Empty).ToString();
            Model.ErrorMessage  = (TempData["Error"] != null ? TempData["Error"].ToString() : string.Empty).ToString();
            return(View(Model));
        }
Ejemplo n.º 5
0
        public ActionResult ViewProfile()
        {
            if (Request.Cookies["User"] != null)
            {
                ViewProfileModel vp = new ViewProfileModel();
                userRepo = new RepositoryFactory().Create <User>();
                User user = ((IUserRepository)userRepo).GetByUserName(Request.Cookies["User"]["userName"]);
                if (user != null)
                {
                    if (user.Password.Equals(Request.Cookies["User"]["userPassword"]))
                    {
                        string[] profilePicture = user.Picture.Split('_');
                        string   tempPicture    = "";
                        for (int i = 0; i < profilePicture.Length; i++)
                        {
                            if (i == 0)
                            {
                                tempPicture += "..";
                            }
                            else if (profilePicture[i].Equals("/") && i > 0)
                            {
                                tempPicture += profilePicture[i] + "..";
                            }
                            else if (!profilePicture[i].Equals("/") && i > 0)
                            {
                                tempPicture += profilePicture[i];
                            }
                        }

                        vp.Name             = user.Name;
                        vp.Email            = user.Email;
                        vp.Gender           = user.Gender;
                        vp.Dob              = user.DateOfBirth.Date;
                        vp.Picture          = tempPicture;
                        vp.Role             = user.Role;
                        vp.Status           = user.Status;
                        vp.RegistrationDate = user.RegistrationDate.Date;
                    }
                }
                else
                {
                    return(RedirectToAction("InValidAccess", "User"));
                }
                return(View("Profile/ViewProfile", vp));
            }
            else
            {
                return(RedirectToAction("InValidAccess", "User"));
            }
        }