public async Task <ActionResult> Create(Models.VM.TravelerProfileVM travelerProfile)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();
                    user        = await userManager.FindByEmailAsync(User.Identity.Name);

                    TravelerProfile profile = new TravelerProfile();
                    PopulateTavelerProfile(profile);
                    profile.SetValues(travelerProfile);
                    Picture pic = ImageProcessing.ReadPicture(travelerProfile.DescriptionVM.upload);
                    if (pic != null)
                    {
                        profile.Description.ProfilePic = pic;
                    }
                    else
                    {
                        profile.Description.ProfilePic = ImageProcessing.ReadPicture(Server.MapPath("~/Images/ProfileBlankPic.png"));
                    }

                    profile.TimeStamp = DateTime.Now;
                    using (var db = new ApplicationDbContext())
                    {
                        db.TravelerProfile.Add(profile);
                        await db.SaveChangesAsync();
                    }
                    user.ProfileID = profile.ID;
                    user.UserType  = "Traveler";
                    await userManager.UpdateAsync(user);

                    NotificationManager.AddNotification(NotificationType.Success, "Travelerprofile successful created");
                    return(RedirectToAction("Index"));
                }
                catch (Exception e)
                {
                    NotificationManager.AddException(e);
                    return(View(travelerProfile));
                }
            }

            return(View(travelerProfile));
        }
        public async Task <ActionResult> Edit(Models.VM.TravelerProfileVM tpVM)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    TravelerProfile tp = await ProfileManager.LoadUserAndTravelerProfile(User);

                    if (tp != null)
                    {
                        using (var db = new ApplicationDbContext())
                        {
                            tp = await LoadProfile(tp.ID);//tp is the updated version

                            TravelerProfile travelerDB = db.TravelerProfile.Find(tp.ID);
                            var             Attributes = await db.TravelerProfileAttributes.FindAsync(tp.TravelerAttributesID);

                            var Description = await db.TravelerProfileDescription.FindAsync(tp.TravelerProfileDescriptionID);

                            var ProfilePic = await db.Pictures.FindAsync(tp.Description.ProfilePic_ID);

                            tp.SetValues(tpVM); //setting old values w/o picture


                            //db.Entry(travelerDB).CurrentValues.SetValues(tp);
                            tp.Attributes.ID = Attributes.ID;
                            db.Entry(Attributes).CurrentValues.SetValues(tp.Attributes);

                            if (ProfilePic != null)                    /// old picture exists           ///Check tp here!! IDs
                            {
                                if (tpVM.DescriptionVM.upload != null) //new upload exists
                                {
                                    //overwrite old Pic


                                    Picture newPic = ImageProcessing.ReadPicture(tpVM.DescriptionVM.upload);

                                    newPic.ID = ProfilePic.ID; //Setting id of old pic id
                                    tp.Description.ProfilePic_ID = newPic.ID;
                                    tp.Description.ProfilePic    = newPic;

                                    db.Entry(ProfilePic).CurrentValues.SetValues(tp.Description.ProfilePic);
                                    db.Entry(Description).CurrentValues.SetValues(tp.Description); //kann denn raus
                                }
                                //do nothing with Pic
                                tp.Description.ID = Description.ID;
                                db.Entry(Description).CurrentValues.SetValues(tp.Description);
                            }
                            else //no old pic exists
                            {
                                if (tpVM.DescriptionVM.upload != null) //new upload exists
                                {
                                    tp.Description.ProfilePic = ImageProcessing.ReadPicture(tpVM.DescriptionVM.upload);
                                    db.Pictures.Add(tp.Description.ProfilePic);
                                    tp.Description.ID = Description.ID;
                                    db.Entry(Description).CurrentValues.SetValues(tp.Description);
                                }
                                tp.Description.ID = Description.ID;
                                db.Entry(Description).CurrentValues.SetValues(tp.Description);
                            }
                            await db.SaveChangesAsync();
                        }
                        NotificationManager.AddNotification(NotificationType.Success, "Profile update successful");
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                catch (Exception e)
                {
                    NotificationManager.AddException(e);
                }
            }
            return(View(tpVM));
        }