Exemplo n.º 1
0
        public async Task <ActionResult> UpdateProfile(AdminUserProfileUpdateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("UpdateProfileModal", model));
            }

            var result = await AdminUserWriter.UpdateProfile(model);

            if (!ModelState.IsWriterResultValid(result))
            {
                return(View("UpdateProfileModal", model));
            }

            //ChatHub.InvalidateUserCache(model.UserId);
            return(CloseModalSuccess(result.Message));
        }
Exemplo n.º 2
0
        public async Task <IWriterResult> UpdateProfile(AdminUserProfileUpdateModel model)
        {
            using (var context = DataContextFactory.CreateContext())
            {
                var profile = await context.UserProfiles.FirstOrDefaultNoLockAsync(x => x.Id == model.Id);

                if (profile == null)
                {
                    return(new WriterResult(false, $"User '{model.UserName}' not found"));
                }

                profile.AboutMe      = model.AboutMe;
                profile.Address      = model.Address;
                profile.Birthday     = model.Birthday;
                profile.City         = model.City;
                profile.ContactEmail = model.ContactEmail;
                profile.Country      = model.Country;
                profile.Education    = model.Education;
                profile.Facebook     = model.Facebook;
                profile.FirstName    = model.FirstName;
                profile.Gender       = model.Gender;
                profile.Hobbies      = model.Hobbies;
                profile.LastName     = model.LastName;
                profile.LinkedIn     = model.LinkedIn;
                //profile.Location = model.Location;
                profile.Occupation = model.Occupation;
                profile.Postcode   = model.Postcode;
                profile.State      = model.State;
                profile.Twitter    = model.Twitter;
                profile.Website    = model.Website;
                //profile.ShowAddress = model.ShowAddress;
                //profile.ShowDetails = model.ShowDetails;
                await context.SaveChangesAsync();

                return(new WriterResult(true, "Successfully updated user profile."));
            }
        }