Exemplo n.º 1
0
        public HttpResponse Create(CreateInputModel inputModel)
        {
            if (!this.IsUserLoggedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            if (inputModel.Name.Length <= 4 && inputModel.Name.Length >= 20)
            {
                return(this.Redirect("/Albums/Create"));
            }

            if (string.IsNullOrWhiteSpace(inputModel.Cover))
            {
                return(this.Redirect("/Albums/Create"));
            }

            albumsService.Create(inputModel.Name, inputModel.Cover);
            return(this.Redirect("/Albums/All"));
        }
Exemplo n.º 2
0
        public HttpResponse Create(CreateAlbumInputModel model)
        {
            if (!this.IsUserLoggedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            if (model.Name.Length < 4 || model.Name.Length > 20)
            {
                return(this.Error("Album name should be between 4 and 20 characters."));
            }

            if (string.IsNullOrEmpty(model.Cover) || string.IsNullOrWhiteSpace(model.Cover) ||
                string.IsNullOrWhiteSpace(model.Name) || string.IsNullOrEmpty(model.Name))
            {
                return(this.Redirect("/Albums/Create"));
            }

            albumsService.Create(model);

            return(this.Redirect("All"));
        }