public Record Add(Record entity) { entity.Id = Guid.NewGuid(); entity.CreateDate = DateTime.Now; entity.LastEditDate = DateTime.Now; return RecordRepository.Add(entity); }
public string GetRecordById(string id) { Record record; if (string.IsNullOrEmpty(id)) record = new Record(); else record = _recordService.Get(new Guid(id)); return JsonConvert.SerializeObject(record); }
public Record Add(Record entity) { var cmdText = "insert into Record (Id,Title,Project,Description,Tag,Status,DealWith,CreateDate,LastEditDate)" + " values (@Id,@Title,@Project,@Description,@Tag,@Status,@DealWith,@CreateDate,@LastEditDate)"; var parameters = new[]{ new SQLiteParameter("@Id",entity.Id.ToString()), new SQLiteParameter("@Title",entity.Title), new SQLiteParameter("@Project",entity.Project), new SQLiteParameter("@Description",entity.Description), new SQLiteParameter("@Tag",entity.Tag), new SQLiteParameter("@Status",entity.Status), new SQLiteParameter("@DealWith",entity.DealWith), new SQLiteParameter("@CreateDate",entity.CreateDate), new SQLiteParameter("@LastEditDate",entity.LastEditDate) }; if (DbContext.ExecuteNoQuery(cmdText, parameters) != 1) throw new Exception("新增记录失败"); return entity; }
public Record Update(Record entity) { var cmdText = "update Record set " + " title = @Title,project = @Project,description = @Description,tag = @Tag,status = @Status,dealwith = @DealWith,CreateDate = @CreateDate,LastEditDate = @LastEditDate" + " where id = @Id"; var parameters = new[]{ new SQLiteParameter("@Id",entity.Id.ToString()), new SQLiteParameter("@Title",entity.Title), new SQLiteParameter("@Project",entity.Project), new SQLiteParameter("@Description",entity.Description), new SQLiteParameter("@Tag",entity.Tag), new SQLiteParameter("@Status",entity.Status), new SQLiteParameter("@DealWith",entity.DealWith), new SQLiteParameter("@CreateDate",entity.CreateDate), new SQLiteParameter("@LastEditDate",entity.LastEditDate) }; if (DbContext.ExecuteNoQuery(cmdText, parameters) != 1) throw new Exception("修改记录失败"); return entity; }
public Record Update(Record entity) { return RecordRepository.Update(entity); }