Beispiel #1
0
 public UserProfileBase UserProfileEditByEmail(UserProfileAdd newItem, string email)
 {
     if (newItem != null)
     {
         var fetchObject = ds.UserProfile.Include("ApplicationUser").SingleOrDefault(e => e.ApplicationUser.UserName == email);
         if (fetchObject == null)
         {
             return(null);
         }
         else
         {
             ds.Entry(fetchObject).CurrentValues.SetValues(newItem);
             ds.SaveChanges();
             return(mapper.Map <UserProfileBase>(fetchObject));
         }
     }
     else
     {
         return(null);
     }
 }
 public ActionResult CreateProfile(UserProfileAdd newItem)
 {
     if (ModelState.IsValid)
     {
         var addedItem = m.UserProfileEditByEmail(newItem, User.Identity.Name);
         if (addedItem == null)
         {
             return(RedirectToAction("index"));
         }
         else
         {
             return(RedirectToAction("Index"));
         }
     }
     else
     {
         var addForm = m.mapper.Map <UserProfileAddForm>(newItem);
         addForm.CountryList       = new SelectList(selectListClass.GetCountriesName());
         addForm.GenderList        = new SelectList(selectListClass.GetGenderAsList());
         addForm.CountryOfBornList = new SelectList(selectListClass.GetCountriesName());
         return(View(addForm));
     }
 }