Example #1
0
 public int Update(ArtistDto value)
 {
     using (KivoDbContext context = new KivoDbContext(Configuration.GetConnectionString("DefaultConnection")))
     {
         return(context.Artist.Udpate(value.ConvertToArtist()));
     }
 }
Example #2
0
 public IEnumerable <ArtistDto> Get()
 {
     using (KivoDbContext context = new KivoDbContext(Configuration.GetConnectionString("DefaultConnection")))
     {
         return(context.Artist.GetAll().Select(s => s.ConvertToArtistDto()));
     }
 }
        public int AddTrack(TrackDto value)
        {
            if (ModelState.IsValid)
            {
                using (KivoDbContext context = new KivoDbContext(Configuration.GetConnectionString("DefaultConnection")))
                {
                    return(context.Track.Add(value.ConvertToTrack()));
                }
            }

            return(0);
        }
Example #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseCors(c =>
                {
                    c.AllowAnyHeader();
                    c.AllowAnyMethod();
                    c.AllowAnyOrigin();
                });
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseRouting();

            app.UseOpenApi();
            app.UseSwaggerUi3();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            using (KivoDbContext context = new KivoDbContext(Configuration.GetConnectionString("DefaultConnection")))
            {
                context.CreateDatabase();
                context.CreateTable();

                if (env.IsDevelopment())
                {
                    context.Artist.Add(new Artist()
                    {
                        ID = Guid.NewGuid(), Active = true, Artist_StageName = "The Weeknd", Artist_LastName = string.Empty, Artist_FirstName = string.Empty, Artist_Birthday = new DateTime(1990, 02, 16), Artist_BirthdayPlace = "Toronto, Ontario (Canada)", Artist_IsMan = true
                    });
                }
            }
        }