public ActionResult Edit(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     Organizer organizer = db.Organizers.Find(id);
     if (organizer == null)
     {
         return HttpNotFound();
     }
     //if organizer is found
     var user = usermanager.FindById(organizer.ApplicationUserID);
     var organizervm = new EditOrganizerViewModel()
     {
         FirstName = organizer.FirstName,
         LastName = organizer.LastName,
         Email = organizer.Email,
         OrganizerTaskID = organizer.OrganizerTaskID,
         OrganizerTypeID = organizer.OrganizerTypeID,
         Phone = organizer.Phone,
         RegNo = organizer.RegNo,
         Username = user.UserName,
         Password = string.Empty,
         ConfirmPassword = string.Empty
     };
     ViewBag.OrganizerTaskID = new SelectList(db.OrganizerTasks, "ID", "Name", organizervm.OrganizerTaskID);
     ViewBag.OrganizerTypeID = new SelectList(db.OrganizerTypes, "ID", "Name", organizervm.OrganizerTypeID);
     return View(organizervm);
 }
 public ActionResult Edit(int id, EditOrganizerViewModel organizervm)
 {
     if (ModelState.IsValid)
     {
         var organizer = db.Organizers.Find(id);
         var user = db.Users.Find(organizer.ApplicationUserID);
         HelperFunctions.CopyPropertyValues(organizervm, organizer);
         user.UserName = organizervm.Username;
         if (organizervm.Password != null)
         {
             usermanager.RemovePassword(user.Id);
             usermanager.AddPassword(user.Id, organizervm.Password);
         }
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.OrganizerTaskID = new SelectList(db.OrganizerTasks, "ID", "Name", organizervm.OrganizerTaskID);
     ViewBag.OrganizerTypeID = new SelectList(db.OrganizerTypes, "ID", "Name", organizervm.OrganizerTypeID);
     return View(organizervm);
 }