public ActionResult Edit(ViewCreateProfile viewCreate, FormCollection collection, HttpPostedFileBase file)
 {
     if (Request.Cookies["user"] != null)
     {
         if (ModelState.IsValid)
         {
             Profile profile = viewCreate.Profile;
             profile.ProfileStatusId = 1;
             profile.Teacher         = new LearningHandler().GetUser(Convert.ToInt32(Request.Cookies["user"]["Id"]));
             profile.PackagePlan     = viewCreate.Profile.PackagePlan;
             profile.CategoryId      = Convert.ToInt32(collection["CategoryId"]);
             profile.SubcategoryId   = Convert.ToInt32(collection["SubCategoryId"]);
             if (file != null)
             {
                 using (MemoryStream ms = new MemoryStream())
                 {
                     file.InputStream.CopyTo(ms);
                     byte[] array = ms.GetBuffer();
                     profile.Image = array;
                 }
             }
             new LearningHandler().EditProfile(profile);
             return(RedirectToAction("Dashboard"));
         }
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
     return(RedirectToAction("Dashboard"));
 }
 public ActionResult EditProfile(int Id)
 {
     if (Request.Cookies["user"] != null)
     {
         ViewCreateProfile vcp = new ViewCreateProfile();
         vcp.Profile = new LearningHandler().GetProfile(Id);
         return(View(vcp));
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }
 public ActionResult CreateProfile()
 {
     if (Request.Cookies["user"] != null)
     {
         ViewCreateProfile V = new ViewCreateProfile();
         V.Subcategory = new LearningHandler().GetSubcategories().ToSelectListItems();
         V.Category    = new LearningHandler().GetCategories().ToSelectListItems();
         return(View(V));
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }
 public ActionResult Edit(int Id)
 {
     if (Request.Cookies["user"] != null)
     {
         ViewCreateProfile vcp = new ViewCreateProfile();
         vcp.Profile         = new LearnContext().Profiles.Find(Id);
         vcp.Profile.Teacher = new LearningHandler().GetUser(Convert.ToInt32(Request.Cookies["user"]["Id"]));
         vcp.Subcategory     = new LearningHandler().GetSubcategories().ToSelectListItems();
         vcp.Category        = new LearningHandler().GetCategories().ToSelectListItems();
         return(View(vcp));
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }
        public ActionResult AddProfile(ViewCreateProfile viewCreateProfile, FormCollection collection, HttpPostedFileBase file)
        {
            int     Id      = Int32.Parse(Request.Cookies["user"]["Id"]);
            Profile profile = new Profile();
            User    teacher = new LearningHandler().GetUser(Id);

            profile               = viewCreateProfile.Profile;
            profile.Teacher       = teacher;
            profile.ProfileStatus = new LearningHandler().GetProfileStatus(1);
            profile.CategoryId    = Convert.ToInt32(collection["CategoryId"]);
            profile.SubcategoryId = Convert.ToInt32(collection["SubCategoryId"]);
            if (file != null)
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    file.InputStream.CopyTo(ms);
                    byte[] array = ms.GetBuffer();
                    profile.Image = array;
                }
            }
            new LearningHandler().AddProfile(profile);
            return(RedirectToAction("Dashboard"));
        }