Ejemplo n.º 1
0
        public DayRating GetDayRatingById(int id)
        {
            using (IDbConnection db = new SqlConnection(_connString))
            {
                string selectQuery = @"SELECT * FROM [dbo].[DayRating] where id = @Id;";

                DayRating result = db.QuerySingle <DayRating>(selectQuery, new { Id = id });
                return(result);
            }
        }
Ejemplo n.º 2
0
        public DayRating AddDayRating(DayRating newDayRating)
        {
            //string connString = Startup.connectionString;
            using (IDbConnection db = new SqlConnection(_connString))
            {
                string insertQuery = @"INSERT INTO [dbo].[DayRating]([Date], [DayRating], DayDetails, DayNotes) 
                OUTPUT Inserted.id 
                VALUES (@Date, @DayRating, @DayDetails, @DayNotes)";

                var result = db.QueryFirst(insertQuery, new
                {
                    newDayRating.Date,
                    newDayRating.DayRatingNum,
                    newDayRating.DayDetails,
                    newDayRating.DayNotes
                });
                newDayRating.Id = int.Parse(result.id.ToString());
            }
            return(newDayRating);
        }
Ejemplo n.º 3
0
        public void UpdateDayRating(int id, DayRating newDayRating)
        {
            using (IDbConnection db = new SqlConnection(_connString))
            {
                string updateQuery = @"Update [dbo].[DayRating] 
                    set [Date] = @Date, 
                    [DayRating] = @DayRating, 
                    DayDetails=@DayDetails,
                    DayNotes=@DayNotes
                    where id = @id";

                var result = db.Execute(updateQuery, new
                {
                    newDayRating.Date,
                    newDayRating.DayRatingNum,
                    newDayRating.DayDetails,
                    newDayRating.DayNotes,
                    newDayRating, id
                });
            }
        }