public ActionResult MyAccount() { var db = new ImageDb(Properties.Settings.Default.ConStr); var user = db.GetByEmail(User.Identity.Name); IEnumerable <Image> images = db.GetImagesForUser(user.Id); return(View(images)); }
public ActionResult SubmitUpload(Image image, HttpPostedFileBase imageFile) { var db = new ImageDb(Properties.Settings.Default.ConStr); var user = db.GetByEmail(User.Identity.Name); image.UserId = user.Id; var fileName = $"{Guid.NewGuid()}{Path.GetExtension(imageFile.FileName)}"; imageFile.SaveAs(Path.Combine(Server.MapPath("/UploadedImages"), fileName)); image.FileName = fileName; db.Add(image); return(View(image)); }