public void Create(AddAllbumInputModel input) { var album = new Album { Name = input.Name, Cover = input.Cover, Price = StartingPrice, }; this.db.Albums.Add(album); this.db.SaveChanges(); }
public HttpResponse Create(AddAllbumInputModel model) { if (!this.IsUserSignedIn()) { return(this.Redirect("/Users/Login")); } if (string.IsNullOrEmpty(model.Name) || model.Name.Length > 20 || model.Name.Length < 4) { return(this.Error("Name should be between 4 and 20 characters!")); } if (string.IsNullOrEmpty(model.Cover)) { return(this.Error("Cover should be valid!")); } this.albumsService.Create(model); return(this.Redirect("/Albums/All")); }