コード例 #1
0
        private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var song = new Song
            {
                name        = Name.Text,
                description = Description.Text,
                singer      = Singer.Text,
                author      = Author.Text,
                thumbnail   = Thumbnail.Text,
                link        = Link.Text,
            };

            Dictionary <String, String> errors = song.Validate();

            if (errors.Count == 0)
            {
                songService.CreateSong(song, fileService.ReadFromTxtFile());
                validateService.ValidateTrue();
                this.NavigationCacheMode = NavigationCacheMode.Disabled;
                this.Frame.Navigate(typeof(SongListOfMine));
            }
            else
            {
                validateService.ValidateFalse(NameMessage, errors, "name");
                validateService.ValidateFalse(SingerMessage, errors, "single");
                validateService.ValidateFalse(ThumbnailMessage, errors, "thumbnail");
                validateService.ValidateFalse(LinkMessage, errors, "link");
                validateService.ValidateFalse(AuthorMessage, errors, "author");
            }
        }
コード例 #2
0
        public IHttpActionResult Post(SongCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var songService = new SongService(Guid.Parse(User.Identity.GetUserId()));

            return(Ok(songService.CreateSong(model)));
        }
コード例 #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var song = new Song()
            {
                name        = this.Name.Text,
                description = this.Description.Text,
                singer      = this.Singer.Text,
                author      = this.Arthor.Text,
                link        = this.Link.Text,
                thumbnail   = this.Thumbnail.Text,
            };

            songService.CreateSong(ProjectConfiguration.CurrentMemberCredential, song);
        }
コード例 #4
0
        public ActionResult Create(SongCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = new SongService();

            if (service.CreateSong(model))
            {
                TempData["SaveResult"] = "Song has been added";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Song was not added");
            return(View(model));
        }