Exemplo n.º 1
0
        public CrashCourseDomain Save(CrashCourseDomain crashCourse)
        {
            var model = CrashCourseModel.From(crashCourse);

            using (var connection = new SqliteConnection(_configuration.GetConnectionString("cnx")))
            {
                connection.Open();

                var row = connection.Execute($"UPDATE {_tableName} SET description = @Description, title = @Title, solution = @Solution, closedAt = @ClosedAt WHERE id = @Id;", model);
            }

            return(model.To());
        }
Exemplo n.º 2
0
        public CrashCourseDomain Save(CrashCourseDomain crashCourse)
        {
            var model = CrashCourseModel.From(crashCourse);

            using (var dbContext = new CrashCourseDBContext(_configuration.GetConnectionString("cnx")))
            {
                dbContext.Database.EnsureCreated();

                dbContext.Entry(model).State = EntityState.Modified;

                dbContext.Update(model);

                dbContext.SaveChanges();
            }

            return(model.To());
        }