コード例 #1
0
        public ActionResult Detail(string eventSlug, string sponsorSlug, CreateOrUpdateSponsor input, HttpPostedFileBase file = null)
        {
            input.Sponsor.Id = Sponsor.IdFrom(eventSlug, sponsorSlug);
            return Execute(input)
                .OnSuccess(x => {
                    if(file != null && file.ContentLength > 0) {
                        imageStorage.Remove(x.Subject.ImageSource);
                        x.Subject.ImageSource = imageStorage.Store(file.FileName, file.InputStream);
                    }

                    return RedirectToAction("Detail", new {eventSlug, sponsorSlug});
                })
                .OnFailure(x => View("CreateOrUpdate", input));
        }
コード例 #2
0
        public ActionResult Index(string eventSlug, CreateOrUpdateSponsor input, HttpPostedFileBase file)
        {
            return Execute(input)
                .OnSuccess(x => {
                    if(file == null || file.ContentLength == 0) {
                        DisplayErrorMessage("You must provide an image.");
                        return View("CreateOrUpdate", input);
                    }

                    x.Subject.ImageSource = imageStorage.Store(file.FileName, file.InputStream);

                    return RedirectToAction("Detail", new {
                        eventSlug,
                        sponsorSlug = Sponsor.SlugFromId(x.Subject.Id)
                    });
                })
                .OnFailure(x => View("CreateOrUpdate", input));
        }