public ActionResult Registration(UserAccount useraccount, HttpPostedFileBase file) { try { if (ModelState.IsValid) { //string ImageName = System.IO.Path.GetFileName(file.FileName); //string physicalPath = Server.MapPath("~/Content/Image/User/" + ImageName); //file.SaveAs(physicalPath); var fileName = FileUploader.FileUpload(this.ControllerContext, "Content/Image/User/").FirstOrDefault(); if (fileName != null) { useraccount.UserImage = fileName; db.UserAccounts.Add(useraccount); db.SaveChanges(); } return(RedirectToAction("Registration")); } } catch (RetryLimitExceededException /* dex */) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } return(View(useraccount)); }
public ActionResult ClassifiedItem(Classifieds_Items citems) { if (Session["user"] != null) { if (ModelState.IsValid) { var files = this.HttpContext.Request.Files; //citems.Date = DateTime.Now; db.Classifieds_Items.Add(citems); var x = FileUploader.FileUpload(this.ControllerContext); foreach (var item in x) { db.Classifieds_Item_Image.Add(new Models.Classifieds_Item_Image() { Classifieds_Items = citems, Classifieds_Item_Image_Name = item }); } db.SaveChanges(); } CategoryIDDropDownList(); return(View()); } else { Session.Clear(); return(RedirectToAction("Login", "Admin")); } }
public ActionResult ClassifiedCategory(Classifieds_Category category) { if (Session["user"] != null) { if (ModelState.IsValid) { var x = FileUploader.FileUpload(this.ControllerContext).FirstOrDefault(); if (x != null && x.Length > 0) { category.Classifieds_Category_Image = x; } db.Classifieds_Category.Add(category); db.SaveChanges(); } return(View()); } else { Session.Clear(); return(RedirectToAction("Login", "Admin")); } }