コード例 #1
0
 public ActionResult Create(CreateImagesViewModel model)
 {
     try
     {
         string FileName = UploadFile(model.File) ?? string.Empty;
         if (ModelState.IsValid)
         {
             if (model.ProjectId == -1)
             {
                 ModelState.AddModelError("", "please review the input fileds");
                 return(View(GetAllProjects()));
             }
             var projects = projectRepository.Find(model.ProjectId);
             var photo    = new Photos
             {
                 Image   = FileName,
                 Project = projects
             };
             imageRepository.Add(photo);
             return(RedirectToAction("index"));
         }
         return(View(model));
     }
     catch
     {
         return(View(model));
     }
 }
コード例 #2
0
        CreateImagesViewModel GetAllProjects()
        {
            var model = new CreateImagesViewModel
            {
                Projects = FillProjects()
            };

            return(model);
        }
コード例 #3
0
        public ActionResult Create()
        {
            var model = new CreateImagesViewModel
            {
                Projects = FillProjects()
            };

            return(View(model));
        }