Example #1
0
        public ActionResult ManageUserInfo(UserViewModel model)
        {
            var tuple = new Tuple<UserViewModel, ManageUserViewModel>(model, new ManageUserViewModel());
            if (ModelState.IsValid)
            {
                try
                {
                    var _db = new ApplicationDbContext();
                    var user = _db.Users.First(u => u.UserName == User.Identity.Name);
                    
                    HttpPostedFileBase file = Request.Files[0] as HttpPostedFileBase;
                    if (file != null && file.ContentLength > 0)
                    {
                        string guid = Guid.NewGuid().ToString();
                        var fileName = Path.GetFileName(file.FileName);
                        var fileExtension = Path.GetExtension(file.FileName);
                        if ((fileExtension == ".jpeg") || (fileExtension == ".jpg") || (fileExtension == ".png"))
                        {
                            user.ProfilePic = guid + fileExtension;
                            var path = Path.Combine(Server.MapPath(@"~/Images/"), guid + fileExtension);
                            file.SaveAs(path);
                        }
                    }
                    user.FullName = model.FullName;
                    user.SkypeName = model.SkypeName;
                    user.TechnologyExpertise = model.TechnologyExpertise;
                    user.Religion = model.Religion;
                    user.Company = model.Company;
                    user.MobileNumber = model.MobileNumber;
                    user.Language = model.Language;
                    user.Interests = model.Interests;
                    user.Location = model.Location;
                    user.OfficeHoursEnd = model.OfficeHoursEnd;
                    user.OfficeHoursStart = model.OfficeHoursStart;
                    user.WantFromTeamMates = model.WantFromTeamMates;
                    user.WantToCollaborate = model.WantToCollaborate;
                    user.Country = model.Country;
                    user.AvailabiltyHours = model.AvailabiltyHours;
                    user.BusinessDomain = model.BusinessDomain;
                    user.Email = model.Email;
                    user.From = model.From;
                    _db.Entry(user).State = EntityState.Modified;
                    _db.SaveChanges();
                    return RedirectToAction("Manage", new { Message = ManageMessageId.SaveUserSuccess });
                }
                catch
                {
                    return RedirectToAction("Manage", new { Message = ManageMessageId.Error });

                }
            }
            return View("Manage", tuple);
        }
Example #2
0
 //
 // GET: /Account/Manage
 public ActionResult Manage(ManageMessageId? message)
 {
     ViewBag.StatusMessage =
         message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
         : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
         : message == ManageMessageId.RemoveLoginSuccess ? "The external login was removed."
         : message == ManageMessageId.Error ? "An error has occurred."
         : message == ManageMessageId.SaveUserSuccess ? "Your profile info. are saved."
         : "";
     ViewBag.HasLocalPassword = HasPassword();
     ViewBag.ReturnUrl = Url.Action("Manage");
     var _db = new ApplicationDbContext();
     string username = User.Identity.Name;
     var user = _db.Users.First(u => u.UserName == username);
     var userModel = new UserViewModel(user);
     var tuple = new Tuple<UserViewModel, ManageUserViewModel>(userModel, new ManageUserViewModel());
     var st = uof.Countries.GetCountryList().Select(f => new SelectListItem() { Text = f.Value, Value = f.Key, Selected = f.Key == user.Country }).ToList();
     if(string.IsNullOrEmpty(user.Country))
         st.Add(new SelectListItem() { Text = "Select", Value = "", Selected=true });
     ViewBag.AllCountries = st;
     return View(tuple);
 }