public async Task <ActionResult> Edit(ProfileIndexViewModel editView)
        {
            if (ModelState.IsValid)
            {
                profile pro = editView.teamProfile;

                var validImageTypes = new string[]
                {
                    "image/gif",
                    "image/jpeg",
                    "image/jpg",
                    "image/png"
                };

                if (editView.picFile != null && editView.picFile.ContentLength > 0)
                {
                    if (!validImageTypes.Contains(editView.picFile.ContentType))
                    {
                        ModelState.AddModelError("ImageUpload", "Please choose either a GIF, JPG or PNG image.");
                    }

                    var uploadDir   = "~/images/teamprofile";
                    var newFileName = String.Format("{0}_{1}_{2}", "Profile", DateTime.Now.ToString("yyyyMMddHHmmssfff"), Path.GetFileName(editView.picFile.FileName));
                    var imagePath   = Path.Combine(Server.MapPath(uploadDir), newFileName);
                    editView.picFile.SaveAs(imagePath);

                    var imageUrl = Path.Combine(uploadDir, Path.GetFileName(imagePath));
                    pro.pic = "~/images/teamprofile/" + newFileName;
                }

                db.Entry(pro).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(editView));
        }
        public async Task <ActionResult> Edit(StoryIndexViewModel editView)
        {
            if (ModelState.IsValid)
            {
                success_story story = editView.successStory;

                var validImageTypes = new string[]
                {
                    "image/gif",
                    "image/jpeg",
                    "image/jpg",
                    "image/png"
                };

                if (editView.picFile != null && editView.picFile.ContentLength > 0)
                {
                    if (!validImageTypes.Contains(editView.picFile.ContentType))
                    {
                        ModelState.AddModelError("ImageUpload", "Please choose either a GIF, JPG or PNG image.");
                    }

                    var uploadDir   = "~/images/successstory";
                    var newFileName = String.Format("{0}_{1}_{2}", "Story", DateTime.Now.ToString("yyyyMMddHHmmssfff"), Path.GetFileName(editView.picFile.FileName));
                    var imagePath   = Path.Combine(Server.MapPath(uploadDir), newFileName);
                    editView.picFile.SaveAs(imagePath);

                    var imageUrl = Path.Combine(uploadDir, Path.GetFileName(imagePath));
                    story.pic = "~/images/successstory/" + newFileName;
                }

                db.Entry(story).State = EntityState.Modified;
                await db.SaveChangesAsync();

                foreach (CategoryCheckBoxModel cat in editView.allCategoryList)
                {
                    if (cat.story_category_id == 0 && cat.isSelected == true)
                    {
                        success_story_category newSsc = new success_story_category();
                        newSsc.success_story_id = story.success_story_id;
                        newSsc.category_id      = cat.category_id;
                        newSsc.status           = 1;
                        db.success_story_category.Add(newSsc);
                        await db.SaveChangesAsync();
                    }
                    if (cat.story_category_id != 0 && cat.isSelected == false)
                    {
                        success_story_category updateSsc = new success_story_category();
                        updateSsc.story_category_id = cat.story_category_id;
                        updateSsc.success_story_id  = story.success_story_id;
                        updateSsc.category_id       = cat.category_id;
                        updateSsc.status            = 0;
                        db.Entry(updateSsc).State   = EntityState.Modified;
                        await db.SaveChangesAsync();
                    }
                }

                foreach (CourseCheckboxModel cor in editView.allCourseList)
                {
                    if (cor.story_course_id == 0 && cor.isSelected == true)
                    {
                        success_story_courses newSsc = new success_story_courses();
                        newSsc.success_story_id = story.success_story_id;
                        newSsc.course_id        = cor.course_id;
                        newSsc.status           = 1;
                        db.success_story_courses.Add(newSsc);
                        await db.SaveChangesAsync();
                    }
                    if (cor.story_course_id != 0 && cor.isSelected == false)
                    {
                        success_story_courses updateSsc = new success_story_courses();
                        updateSsc.story_course_id  = cor.story_course_id;
                        updateSsc.success_story_id = story.success_story_id;
                        updateSsc.course_id        = cor.course_id;
                        updateSsc.status           = 0;
                        db.Entry(updateSsc).State  = EntityState.Modified;
                        await db.SaveChangesAsync();
                    }
                }
                return(RedirectToAction("Index"));
            }

            return(View(editView));
        }