/// <summary> /// Diaryアイテムを追加します。 /// </summary> /// <param name="diary"></param> /// <returns></returns> public DiaryItem Add(DiaryItem diary) { if (string.IsNullOrEmpty(diary.Id)) { diary.Id = Guid.NewGuid().ToString(); } // Save var cl = GetDatabaseClient(); var sql = $"insert into [DIARY] (Id,Title,Contents,CreatedDate,Password,UserName) VALUES (@Id,@Title,@Contents,@CreatedDate,@Password,@UserName)"; var p = new Dictionary <string, object> { { "Id", diary.Id }, { "Title", diary.Title }, { "Contents", diary.Contents }, { "CreatedDate", diary.CreatedDate }, { "Password", diary.Password }, { "UserName", diary.UserName } }; cl.ExecuteSql(sql, p); // Get return(Get(diary.Id)); }
/// <summary> /// Diaryアイテムを更新します。 /// </summary> /// <param name="diary"></param> /// <returns></returns> public DiaryItem Update(DiaryItem diary) { // Save var cl = GetDatabaseClient(); var sql = $"update DIARY set Title = @Title, Contents = @Contents,CreatedDate =@CreatedDate,Password=@Password where Id = @Id"; var p = new Dictionary <string, object> { { "Id", diary.Id }, { "Title", diary.Title }, { "Contents", diary.Contents }, { "CreatedDate", diary.CreatedDate }, { "Password", diary.Password }, { "UserName", diary.UserName } }; cl.ExecuteSql(sql, p); // Get return(Get(diary.Id)); }