public ActionResult Create(FormCollection objForm, Course course, HttpPostedFileBase file)
        {
            var courseName = string.Empty;
            var loggedUserID = string.Empty;
            var guidFileName = string.Empty;
            if (ModelState.IsValid)
            {
                loggedUserID = Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString();

                if (!string.IsNullOrEmpty(objForm["coursecategory"]))
                {
                    courseName = objForm["coursecategory"];
                    CourseCategory objcategory = new CourseCategory();
                    objcategory.CategoryName = courseName;
                    db.Course_Category.Add(objcategory);
                    db.SaveChanges();

                    course.CourseCategoryId = objcategory;
                    course.Userid = Convert.ToInt32(loggedUserID);
                }
                if (file != null)
                {
                    if (file.ContentLength > 0)
                    {
                        var fileInfoObj = new FileInfo(file.FileName);
                        var guid = Guid.NewGuid().ToString().ToUpper();
                        guidFileName = guid + fileInfoObj.Extension.ToLower();
                        var path = Path.Combine(Server.MapPath("~/UploadedImages/"), guidFileName);
                        if (!Directory.Exists(Server.MapPath("~/UploadedImages/")))
                        {
                            Directory.CreateDirectory(Server.MapPath("~/UploadedImages/"));
                        }
                        file.SaveAs(path);
                    }
                }

                //temporary code
                course.CourseImgURl = guidFileName;
                db.Courses.Add(course);
                db.SaveChanges();

                return RedirectToAction("Index");
            }

            return View(course);
        }
 public ActionResult Edit(Course course)
 {
     if (ModelState.IsValid)
     {
         db.Entry(course).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(course);
 }