예제 #1
0
        public ActionResult Index(SubmissionModel model)
        {
            if (ModelState.IsValid)
            {
                var    uploadPath       = Server.MapPath("~/App_Data/Uploads");
                string uploadedFilePath = Path.Combine(uploadPath, model.FileName);
                Image  img   = Image.FromFile(uploadedFilePath);
                var    photo = new Photo
                {
                    Title       = model.Title,
                    Description = model.Description,
                    FileName    = model.FileName,
                    Width       = img.Width,
                    Height      = img.Height,
                    UserId      = CurrentUser.Id
                };
                var photoId = _photoManager.CreatePhoto(photo);

                _tagManager.CreateTag(model.Tags, photoId);

                return(RedirectToAction("MyPhotos", "Gallery"));
            }

            return(View(model));
        }