public ActionResult Main(UploadViewModel upload) { portfolioContext context = new portfolioContext(); if (!ModelState.IsValid) { return(View("Index", upload)); } int id = Convert.ToInt32(upload.Works.Filter); var filtervalue = context.filters.SingleOrDefault(x => x.Id == id); HttpPostedFileBase image = Request.Files["Image"]; byte[] bytes = null; using (BinaryReader br = new BinaryReader(image.InputStream)) { bytes = br.ReadBytes(image.ContentLength); } Works work = new Works { Image = bytes, Description = upload.Works.Description, Title = upload.Works.Title, Filter = filtervalue.Filter, DT = DateTime.Now }; context.Works.Add(work); context.SaveChanges(); return(RedirectToAction("Main", "Admin")); }
public ActionResult Index(Login login) { portfolioContext context = new portfolioContext(); if (!ModelState.IsValid) { // return Content("call"); return(View("Index", login)); } var userExistence = context.Logins.SingleOrDefault(x => x.UserName == login.UserName); if (userExistence == null) { ViewBag.usernotexist = "User Does Not Exists"; return(View("Index")); } else if (!string.Equals(userExistence.Password, login.Password)) { ViewBag.incorrectpassword = "******"; return(View("Index")); } else if (string.Equals(userExistence.Password, login.Password)) { Session["User"] = userExistence.UserName; return(RedirectToAction("Main", "Admin")); } return(View("Index")); }
// GET: Portfolio public ActionResult Index() { portfolioContext context = new portfolioContext(); var work = context.Works.OrderByDescending(x => x.DT).ToList(); return(View(work)); }
public ActionResult Main() { portfolioContext context = new portfolioContext(); var FilterType = context.filters.ToList(); var viewmodel = new UploadViewModel { filters = FilterType }; return(View(viewmodel)); }