public IActionResult MyProfile(string username)
        {
            if (this.User.Identity.Name != username)
            {
                return this.Redirect(Constants.homeUrl);
            }

           var companyProfile = this.profileService.GetCompanyProfileWithUsername(username);

            if (companyProfile == null)
            {
                return this.Redirect(Constants.homeUrl);
            }

            var categories = string.Join(",", companyProfile.Categories.Select(x => x.Name));

            var model = new ProfileDetailsViewModel
            {
                Email = companyProfile.Account.Email,
                Description = companyProfile.Description,
                Name = companyProfile.Name,
                Account = companyProfile.Account,
                Rating = companyProfile.Rating,
                Categories = categories,
            };

            return this.View(model);



        }
示例#2
0
        public IActionResult Details(string id)
        {
            var user = UserManager.Users
                       .Include(u => u.Recipes).Include(u => u.Files)
                       .Include(u => u.FavouriteRecipes)
                       .ThenInclude(fr => fr.Recipe)
                       .FirstOrDefault(u => u.Id == id);

            var profilePicture = ProfilePictureService.GetUserAvatar(user.Id);

            var path = ProfilePictureService.GetAvatarPath(profilePicture);

            if (path != null)
            {
                ViewData["AvatarPath"] = path;
            }

            var vm = new ProfileDetailsViewModel()
            {
                User           = user,
                MealCategories = Context.Categories.ToList(),
            };

            return(View("Details", vm));
        }
        // GET: Profile/DetailsUser/5
        public async Task <IActionResult> DetailsUser(string?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var model = new ProfileDetailsViewModel();

            model.UserInventory = await _DataAccess.UserInventoryDataAccess.GetUserInventoryByUserAsync(id);

            if (model.UserInventory == null)
            {
                return(NotFound());
            }

            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); // will give the user's userId

            model.LifePoints = await _DataAccess.TradeDataAccess.GetUserRating(id);

            model.IsOwn    = userId == model.UserInventory?.ApplicationUserId && !string.IsNullOrEmpty(userId);
            model.Listings = await _DataAccess.TradeDataAccess.GetTradeListingsByUser(model.UserInventory?.ApplicationUserId);

            model.UserName = model.UserInventory?.Email;
            return(View("Details", model));
        }
        public JsonResult GetProfileDetails()
        {
            var profileDetailsViewModel = new ProfileDetailsViewModel();
            var user = _userService.GetById(WebSecurity.CurrentUserId);

            if (user != null)
            {
                profileDetailsViewModel.ActiveTasksCount      = _taskService.CountAllByUserId(WebSecurity.CurrentUserId, false);
                profileDetailsViewModel.ArchivedTasksCount    = _taskService.CountAllByUserId(WebSecurity.CurrentUserId, true);
                profileDetailsViewModel.CompletedTasksCount   = _taskService.CountCompletedTaskItemsByUserId(WebSecurity.CurrentUserId);
                profileDetailsViewModel.CompletedMinutesCount = _taskService.CountCompletedMinutesByUserId(WebSecurity.CurrentUserId);

                profileDetailsViewModel.UserDetails = new UserDetailsViewModel
                {
                    Id             = user.Id,
                    Email          = user.Email,
                    Name           = user.Name,
                    DateRegistered = user.DateRegistered
                };
            }
            else
            {
                throw new MyException("An authorization error occurred.");
            }

            return(Json(_validationHelper.ModelStateToJsonResult(ModelState, profileDetailsViewModel)));
        }
示例#5
0
        public async Task <IActionResult> Edit(ProfileEditInputModel inputModel)
        {
            if (!ModelState.IsValid)
            {
                return(this.View());
            }

            await this.userService.Edit(inputModel.Id, inputModel.FullName);

            var userFromDb = await this.userService.GetById(inputModel.Id);

            List <ProfileItemViewModel> itemsSold = userFromDb.ItemsAuctioned.Select(item => new ProfileItemViewModel
            {
                Name    = item.Name,
                Picture = item.Picture
            }).ToList();

            var viewModel = new ProfileDetailsViewModel
            {
                Id             = userFromDb.Id,
                Username       = userFromDb.UserName,
                FullName       = userFromDb.FullName,
                ItemsAuctioned = itemsSold
            };

            return(this.View(BasicConstants.ProfileRoute, viewModel));
        }
示例#6
0
        public ActionResult Index()
        {
            var user = new ProfileDetailsViewModel();

            if (String.IsNullOrEmpty(User.Identity.Name))
            {
                RedirectToAction("Login", "Account");
            }

            using (var unitOfWork = new UnitOfWork())
            {
                var result = unitOfWork.GetProfileDetailsByUsername(User.Identity.Name);

                if (result != null)
                {
                    user = new ProfileDetailsViewModel()
                    {
                        Username      = result.Username,
                        Name          = result.Name,
                        ContactNumber = result.ContactNumber,
                        Profession    = result.Profession,
                        ProfileId     = result.ProfileId
                    };
                    return(View(user));
                }
                else
                {
                    return(RedirectToAction("CreateProfile"));
                }
            }
        }
        public ActionResult UserProfile()
        {
            ProfileDetailsViewModel model = new ProfileDetailsViewModel();

            model.User = UserManager.FindById(User.Identity.GetUserId());

            if (model.User == null)
            {
                return(HttpNotFound());
            }

            model.PageTitle       = "Profile";
            model.PageDescription = "Review your profile";
            model.PageURL         = Url.UserProfile().ToSiteURL();
            model.PageImageURL    = PictureHelper.UserAvatarSource(model.User.Picture);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_UserProfile", model));
            }
            else
            {
                return(View(model));
            }
        }
        public async Task <ActionResult> ChangeAvatar()
        {
            ProfileDetailsViewModel model = new ProfileDetailsViewModel();

            model.User = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            return(PartialView("_ChangeAvatar", model));
        }
示例#9
0
        // GET: /<controller>/
        public async Task <IActionResult> Index(Guid id)
        {
            var user = await userManager.FindByIdAsync(id.ToString());

            var viewerId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (user.Id == viewerId)
            {
                ViewBag.editable = true;
            }
            else
            {
                ViewBag.editable = false;
            }

            var posts = _fixtures.GetUsersPost(id);

            var userStreak = _fixtures.GetUserStreak(id);

            var userPosts = new List <ListPostViewModel>();

            foreach (var post in posts)
            {
                var poster = await userManager.FindByIdAsync(post.AppUserId.ToString());

                var streak = _fixtures.GetUserStreak(post.AppUserId);

                var up = new ListPostViewModel
                {
                    PostDate = post.PostDate.Humanize(),
                    Comments = post.Comments,
                    Fixture  = _fixtures.GetMatchById(post.MatchId),
                    Id       = post.Id,
                    Image    = poster.Image,
                    Thoughts = post.Thoughts,
                    Tip      = post.Tip,
                    UserId   = post.AppUserId,
                    Streak   = streak
                };
                userPosts.Add(up);
            }

            ProfileDetailsViewModel model = new ProfileDetailsViewModel
            {
                User       = user,
                Posts      = userPosts,
                UserStreak = userStreak
            };

            if (user != null)
            {
                //Instantiate and return ProfileVM
                return(View(model));
            }

            return(NotFound());
        }
        public IActionResult Details()
        {
            var userId = _db.RCTHUsers
                         .FirstOrDefault(u => u.UserName == User.Identity.Name)
                         .Id;
            //get required user data from database
            ProfileDetailsViewModel model = _db.RCTHUsers
                                            .Include(u => u.BloodGroup)
                                            .Select(u => new ProfileDetailsViewModel()
            {
                UserName    = u.UserName,
                FirstName   = u.FirstName,
                LastName    = u.LastName,
                Age         = u.Age,
                BloodGroup  = u.BloodGroup,
                PhoneNumber = u.PhoneNumber
            })
                                            .FirstOrDefault(u => User.Identity.Name == u.UserName);

            //check if user has made a donation then update his bloodgroup
            if (model.BloodGroup == null)
            {
                model.BloodGroup = _db.Donations
                                   .Include(d => d.BloodGroup)
                                   .Where(d => d.UserId == userId)
                                   .OrderByDescending(d => d.dateDonated)
                                   .Select(d => d.BloodGroup)
                                   .FirstOrDefault();

                //update user's bloodgroup after a successful bloodtest
                _db.RCTHUsers
                .Include(u => u.BloodGroup)
                .FirstOrDefault(u => u.Id == userId)
                .BloodGroup = model.BloodGroup;
                _db.SaveChanges();
            }
            var donationView = _db.Donations
                               .Where(d => d.UserId == userId)
                               .OrderByDescending(d => d.dateDonated)
                               .Select(d => new ProfileDetailsViewModel.DonationView()
            {
                Date     = d.dateDonated,
                Id       = d.Id,
                Quantity = d.Quantity,
                Receiver = d.Receiver
            })
                               .ToList();

            //Assign Donation Data
            model.DonationData      = donationView;
            model.LastBloodDonation = donationView.Select(d => d.Date).FirstOrDefault();
            //create view model
            return(View("Details", model));
        }
示例#11
0
        public ActionResult Index(string id)
        {
            ProfileCache profileCacheObj = (this.MobiContext.Service.Cache as ChatCache).GetProfileByID(id);

            if (profileCacheObj == null)
            {
                Log.Error("Could not load profile with iD:{0} from cache");
                return(this.InternalError());
            }

            ProfileDetailsViewModel model = new ProfileDetailsViewModel(this.MobiContext, profileCacheObj);

            return(View("ChatProfileDetails", model));
        }
示例#12
0
        public async Task <IActionResult> Details(string username)
        {
            var user = await _userManager.FindByNameAsync(username);

            var posts = _postService.GetAll().Where(p => p.CreatedBy == user.Id).OrderByDescending(a => a.CreatedAt).Take(20).ToList();
            var vm    = new ProfileDetailsViewModel()
            {
                User = user,
                CreatedCommunities = _communityService.GetAll().Where(p => p.CreatedBy == user.Id).ToList(),
                Comments           = _commentService.GetAll().Where(p => p.CreatedBy == user.Id).ToList(),
                Posts = posts.ConvertToProfilePostDetailsViewModel(_commentService)
            };

            return(View(vm));
        }
示例#13
0
        public ActionResult Edit(ProfileDetailsViewModel profile)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    unitOfWork.UpdateProfileDetailsByUsername(profile.Name, profile.ContactNumber, profile.Profession, User.Identity.Name);
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#14
0
        public async Task <ActionResult> Details()
        {
            var userId  = GetCurrentUserId();
            var profile = await _profileService.GetProfileByUserIdAsync(userId);

            var model = new ProfileDetailsViewModel
            {
                Email       = profile.Email,
                FirstName   = profile.FirstName,
                LastName    = profile.LastName,
                Group       = profile.Group?.Title,
                GroupNumber = profile.Group.Number
            };

            return(View(model));
        }
示例#15
0
        public ActionResult Details(string id)
        {
            var user = regularUserService.GetById(id);

            if (user != null)
            {
                IEnumerable <ProjectCreateViewModel> projects = null;
                if (user.Projects != null && user.Projects.Count > 0)
                {
                    projects = user.Projects.Select(
                        p => new ProjectCreateViewModel()
                    {
                        Id    = p.Id,
                        Title = p.Title
                    });
                }

                IEnumerable <StoryCreateViewModel> stories = null;
                if (user.Stories != null && user.Stories.Count > 0)
                {
                    stories = user.Stories.Select(
                        s => new StoryCreateViewModel()
                    {
                        Id    = s.Id,
                        Title = s.Title
                    });
                }

                var viewModel = new ProfileDetailsViewModel()
                {
                    CarManiacForDays = (int)(DateTime.Now - user.RegisterDate).TotalDays,
                    AvatarUrl        = user.AvatarUrl,
                    FirstName        = user.FirstName,
                    LastName         = user.LastName,
                    Age                 = user.Age,
                    CurrentCar          = user.CurrentCar,
                    FavoriteCar         = user.FavoriteCar,
                    Projects            = projects,
                    Stories             = stories,
                    IsUserAllowedToEdit = this.User.Identity.GetUserId() == user.Id
                };
                return(View(viewModel));
            }

            return(new HttpNotFoundResult());
        }
示例#16
0
        public async Task <IActionResult> Profile()
        {
            var userId = User.Identity.GetUserId();
            var user   = await userManage.Users.FirstOrDefaultAsync(e => e.Id == userId);

            if (user == null)
            {
                Response.StatusCode = 404;
                return(View("UserNotFound", userId));
            }

            ProfileDetailsViewModel profileDetailsViewModel = new ProfileDetailsViewModel()
            {
                User      = user,
                PageTitle = "User Profile"
            };

            return(View(profileDetailsViewModel));
        }
        // GET: Profile/Details
        public ActionResult Details()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            //This is where the user's account information will go.
            if (User.IsInRole("Admin"))
            {
                return(RedirectToAction("Index", "User"));
            }
            else if (User.IsInRole("Employee"))
            {
                return(RedirectToAction("Pickups", "Profile", new { todayOnly = true }));
            }
            else
            {
                //This is the customer role view. Not a great structure. Should re-do this.
                //get list of invoices that the user owns that are unpaid. Calculate total amount due.
                var userId   = User.Identity.GetUserId();
                var invoices = db.Invoices
                               .Include(i => i.Pickups)
                               .Where(i => i.UserId == userId)
                               .Where(i => i.IsPaid == false)
                               .ToList();

                double totalAmountDue = 0d;
                foreach (Invoice invoice in invoices)
                {
                    totalAmountDue += invoice.AmountDue;
                }
                //create a view model
                //populate it with the list of invoices and total amount due. Unless you want to get cray and put that logic in the view.
                var viewModel = new ProfileDetailsViewModel();
                viewModel.Invoices  = invoices;
                viewModel.AmountDue = totalAmountDue;

                return(View(viewModel));
            }
        }
示例#18
0
        public ActionResult Edit()
        {
            if (!String.IsNullOrEmpty(User.Identity.Name))
            {
                var result = unitOfWork.GetProfileDetailsByUsername(User.Identity.Name);

                if (result != null)
                {
                    var user = new ProfileDetailsViewModel()
                    {
                        Username      = result.Username,
                        Name          = result.Name,
                        ContactNumber = result.ContactNumber,
                        Profession    = result.Profession
                    };

                    return(View(user));
                }
            }

            return(RedirectToAction("Login", "Account"));
        }
示例#19
0
        public async Task <IActionResult> ProfileDetails()
        {
            var id = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            AuctionUser user = await this.userService.GetById(id);

            List <ProfileItemViewModel> items = user.ItemsAuctioned.Select(item => new ProfileItemViewModel
            {
                Name    = item.Name,
                Picture = item.Picture
            }).ToList();

            var viewModel = new ProfileDetailsViewModel
            {
                Id             = user.Id,
                Username       = user.UserName,
                FullName       = user.FullName,
                ItemsAuctioned = items
            };

            return(View(viewModel));
        }
示例#20
0
        public async Task <IActionResult> Details()
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            ViewBag.User = user.FirstName + " " + user.LastName;

            var applicationUser = user;

            if (applicationUser == null)
            {
                return(NotFound());
            }

            var chapters = await _context.MemberChapters
                           .Include(mc => mc.Chapter)
                           .Where(mc => mc.ApplicationUserId == applicationUser.Id && mc.WhenExpires >= DateTime.Now)
                           .ToListAsync();

            var viewModel = new ProfileDetailsViewModel
            {
                Id            = applicationUser.Id,
                FirstName     = applicationUser.FirstName,
                LastName      = applicationUser.LastName,
                Street1       = applicationUser.Street1,
                Street2       = applicationUser.Street2,
                City          = applicationUser.City,
                State         = applicationUser.State,
                ZipCode       = applicationUser.ZipCode,
                Phone         = applicationUser.PhoneNumber,
                Email         = applicationUser.Email,
                WhenJoined    = applicationUser.WhenJoined,
                WhenExpires   = applicationUser.WhenExpires,
                Notes         = await _context.ApplicationUserNotes.Where(n => n.ApplicationUserId == applicationUser.Id).OrderByDescending(n => n.WhenAdded).ToListAsync(),
                Chapters      = chapters,
                SecurityGroup = applicationUser.SecurityGroup
            };

            return(View(viewModel));
        }
示例#21
0
        public IActionResult Details(string id)
        {
            var user = userManager.Users
                       .Include(u => u.Recipes).Include(u => u.Files)
                       .Include(u => u.FavouriteRecipes)
                       .FirstOrDefault(u => u.Id == id);

            var picture = context.ProfilePictures.Where(p => p.UserId == user.Id)
                          .FirstOrDefault(f => f.FileType == FileType.Avatar);

            var vm = new ProfileDetailsViewModel()
            {
                User           = user,
                MealCategories = context.Categories.ToList(),
            };

            if (picture != null)
            {
                ViewData["AvatarPath"] = "data:image/jpeg;base64," + Convert.ToBase64String(picture.Content, 0, picture.Content.Length);
            }

            return(View("Details", vm));
        }
示例#22
0
        public async Task <IActionResult> Index(string userId)
        {
            var questions = await _questionCommands.GetUserQuestions(userId);

            var questionAnswers = _answersCommand.GetQuestionsWithAnswers(userId);
            var user            = await _requestUserProvider.GetUserByUserId(userId);

            ViewBag.questionCount = _questionCommands.GetUserQuestions(userId)
                                    .Result.Count();
            var countQuestionAnsweres = _answersCommand.GetQuestionsWithAnswers(userId)
                                        .AsQueryable().Count();

            ViewBag.questionAnswersCount = countQuestionAnsweres;


            var viewModel = new ProfileDetailsViewModel
            {
                AskedQuestions  = questions,
                QuestionAnswers = questionAnswers,
                User            = user
            };

            return(View(viewModel));
        }
示例#23
0
 public void SetVM(ProfileDetailsViewModel viewModel)
 {
     ProfileViewModel = viewModel;
 }
示例#24
0
        public async Task <IActionResult> GetUserProfile([FromRoute] string id)
        {
            var errorMessage = new ErrorMessageViewModel();
            var error        = new { Error = errorMessage };

            // Get the user profile
            ApplicationUser user = db.ApplicationUser.Where(e => e.Id == id).SingleOrDefault();

            if (user == null)
            {
                errorMessage.Message = "Could not find the user profile";
                return(Json(error));
            }

            // Find the user type based on the id
            BusinessUsers businessUser = db.BusinessUsers.Where(e => e.UserId == id).SingleOrDefault();

            if (businessUser == null)
            {
                BusinessEmployees employee = db.BusinessEmployees.Where(e => e.UserId == id).SingleOrDefault();

                if (employee == null)
                {
                    PersonalUsers personalUser = db.PersonalUsers.Where(e => e.UserId == id).SingleOrDefault();

                    if (personalUser == null)
                    {
                        errorMessage.Message = "Could not find the profile for the user";
                        return(Json(error));
                    }

                    // Get the personal user details
                    ProfileDetailsViewModel personalProfile = new ProfileDetailsViewModel
                    {
                        Id             = personalUser.UserId,
                        FirstName      = personalUser.FirstName,
                        LastName       = personalUser.LastName,
                        Email          = user.Email,
                        AccountType    = "Personal",
                        ProfilePicture = personalUser.ProfilePicture
                    };

                    return(Ok(personalProfile));
                }

                // Get the employer info
                BusinessUsers employer = db.BusinessUsers.Where(e => e.BusinessUserId == employee.BusinessUserId).SingleOrDefault();

                if (employer == null)
                {
                    errorMessage.Message = "Could not find the employer profile for the employee";
                    return(Json(error));
                }

                // Get the employee user details
                EmployeeDetailsViewModel employeeProfile = new EmployeeDetailsViewModel
                {
                    Id             = employee.UserId,
                    FirstName      = employee.FirstName,
                    LastName       = employee.LastName,
                    Email          = user.Email,
                    AccountType    = "Employee",
                    ProfilePicture = employee.ProfilePicture,
                    Organization   = employer.Organization,
                    CanEditLibrary = employee.CanEditLibrary
                };

                return(Ok(employeeProfile));
            }

            // Get the business user details
            ProfileDetailsViewModel businessProfile = new ProfileDetailsViewModel
            {
                Id             = businessUser.UserId,
                FirstName      = businessUser.FirstName,
                LastName       = businessUser.LastName,
                Email          = user.Email,
                AccountType    = "Business",
                ProfilePicture = businessUser.ProfilePicture,
                Organization   = businessUser.Organization
            };

            return(Ok(businessProfile));
        }
示例#25
0
        public async Task <IActionResult> UpdateProfile([FromRoute] string id, [FromBody] ProfileDetailsViewModel profile)
        {
            var errorMessage = new ErrorMessageViewModel();
            var error        = new { Error = errorMessage };

            var role = "";

            if (User != null)
            {
                try
                {
                    role = User.Claims.Where(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").SingleOrDefault().Value;

                    if (role == null)
                    {
                        errorMessage.Message = "Could not find role for user";
                        return(Json(error));
                    }
                }
                catch (Exception exception)
                {
                    errorMessage.Message = "Could not get role for user";
                    return(Json(error));
                }
            }

            if (profile == null)
            {
                errorMessage.Message = "Model is missing data";
                return(Json(error));
            }

            // Find the type of user based on the role
            if (role == "Personal")
            {
                // Get the personal user in the database
                PersonalUsers personalUser = db.PersonalUsers.Where(e => e.UserId == id).SingleOrDefault();

                // Update the details for the profile
                if (personalUser != null)
                {
                    personalUser.FirstName = profile.FirstName;
                    personalUser.LastName  = profile.LastName;

                    if (!String.IsNullOrWhiteSpace(profile.ProfilePicture))
                    {
                        var fileName = await fileController.UploadImage(profile.ProfilePicture, Request);

                        if (String.IsNullOrWhiteSpace(fileName))
                        {
                            errorMessage.Message = "Image upload encountered an error";
                            return(Json(error));
                        }

                        personalUser.ProfilePicture = fileName;
                    }

                    // Update record in the database
                    db.Entry(personalUser).State = EntityState.Modified;

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception exception)
                    {
                        errorMessage.Message = "Could update the account information";
                        return(Json(error));
                    }

                    return(Ok(personalUser));
                }
                else
                {
                    errorMessage.Message = "Could not find the user profile";
                    return(Json(error));
                }
            }
            else if (role == "Business")
            {
                // Get the business user in the database
                BusinessUsers businessUser = db.BusinessUsers.Where(e => e.UserId == id).SingleOrDefault();

                // Update the details for the profile
                if (businessUser != null)
                {
                    businessUser.FirstName    = profile.FirstName;
                    businessUser.LastName     = profile.LastName;
                    businessUser.Organization = profile.Organization;
                    businessUser.PhoneNumber  = profile.PhoneNumber;

                    if (!String.IsNullOrWhiteSpace(profile.ProfilePicture))
                    {
                        var fileName = await fileController.UploadImage(profile.ProfilePicture, Request);

                        if (String.IsNullOrWhiteSpace(fileName))
                        {
                            errorMessage.Message = "Image upload encountered an error";
                            return(Json(error));
                        }

                        businessUser.ProfilePicture = fileName;
                    }

                    // Update record in the database
                    db.Entry(businessUser).State = EntityState.Modified;

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception exception)
                    {
                        errorMessage.Message = "Could update the account information";
                        return(Json(error));
                    }

                    return(Ok(businessUser));
                }
                else
                {
                    errorMessage.Message = "Could not find the user profile";
                    return(Json(error));
                }
            }
            else if (role == "Employee")
            {
                // Get the employee in the database
                BusinessEmployees employee = db.BusinessEmployees.Where(e => e.UserId == id).SingleOrDefault();

                // Update the details for the profile
                if (employee != null)
                {
                    employee.FirstName   = profile.FirstName;
                    employee.LastName    = profile.LastName;
                    employee.PhoneNumber = profile.PhoneNumber;

                    if (!String.IsNullOrWhiteSpace(profile.ProfilePicture))
                    {
                        var fileName = await fileController.UploadImage(profile.ProfilePicture, Request);

                        if (String.IsNullOrWhiteSpace(fileName))
                        {
                            errorMessage.Message = "Image upload encountered an error";
                            return(Json(error));
                        }

                        employee.ProfilePicture = fileName;
                    }

                    // Update record in the database
                    db.Entry(employee).State = EntityState.Modified;

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception exception)
                    {
                        errorMessage.Message = "Could update the account information";
                        return(Json(error));
                    }

                    return(Ok(employee));
                }
                else
                {
                    errorMessage.Message = "Could not find the user profile";
                    return(Json(error));
                }
            }

            errorMessage.Message = "An error has occurred";
            return(Json(error));
        }
示例#26
0
        public async Task <IActionResult> Profile()
        {
            ProfileDetailsViewModel model = await _mediator.Send(new GetProfileDetailsQuery());

            return(View(model));
        }
示例#27
0
        public async Task <IActionResult> UpdateCustomer(ProfileDetailsViewModel model)
        {
            await _mediator.Send(new UpdateCustomerCommand { Customer = model.Customer });

            return(RedirectToAction("Profile"));
        }