public static Common.Models.Timing.Time Edit( Common.Models.Timing.Time model, Common.Models.Account.Users modifier, IDbConnection conn = null, bool closeConnection = true) { model.ModifiedBy = modifier; model.Modified = DateTime.UtcNow; DBOs.Timing.Time dbo = Mapper.Map <DBOs.Timing.Time>(model); conn = DataHelper.OpenIfNeeded(conn); if (dbo.TimeCategoryId.HasValue && dbo.TimeCategoryId.Value == 0) { dbo.TimeCategoryId = null; } conn.Execute("UPDATE \"time\" SET " + "\"start\"=@Start, \"stop\"=@Stop, \"worker_contact_id\"=@WorkerContactId, \"time_category_id\"=@TimeCategoryId, \"details\"=@Details, \"billable\"=@Billable, \"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " + "WHERE \"id\"=@Id", dbo); DataHelper.Close(conn, closeConnection); return(model); }
public static Common.Models.Timing.Time Create( Common.Models.Timing.Time model, Common.Models.Account.Users creator, IDbConnection conn = null, bool closeConnection = true) { if (!model.Id.HasValue) { model.Id = Guid.NewGuid(); } model.CreatedBy = model.ModifiedBy = creator; model.Created = model.Modified = DateTime.UtcNow; DBOs.Timing.Time dbo = Mapper.Map <DBOs.Timing.Time>(model); conn = DataHelper.OpenIfNeeded(conn); if (dbo.TimeCategoryId.HasValue && dbo.TimeCategoryId.Value == 0) { dbo.TimeCategoryId = null; } conn.Execute("INSERT INTO \"time\" (\"id\", \"start\", \"stop\", \"worker_contact_id\", \"time_category_id\", \"details\", \"billable\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " + "VALUES (@Id, @Start, @Stop, @WorkerContactId, @TimeCategoryId, @Details, @Billable, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)", dbo); DataHelper.Close(conn, closeConnection); return(model); }
public static Common.Models.Timing.Time Edit(Common.Models.Timing.Time model, Common.Models.Account.Users modifier) { model.ModifiedBy = modifier; model.Modified = DateTime.UtcNow; DBOs.Timing.Time dbo = Mapper.Map <DBOs.Timing.Time>(model); using (IDbConnection conn = Database.Instance.GetConnection()) { conn.Execute("UPDATE \"time\" SET " + "\"start\"=@Start, \"stop\"=@Stop, \"worker_contact_id\"=@WorkerContactId, \"details\"=@Details, \"billable\"=@Billable, \"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " + "WHERE \"id\"=@Id", dbo); } return(model); }
public static Common.Models.Timing.Time Create(Common.Models.Timing.Time model, Common.Models.Account.Users creator) { if (!model.Id.HasValue) { model.Id = Guid.NewGuid(); } model.CreatedBy = model.ModifiedBy = creator; model.Created = model.Modified = DateTime.UtcNow; DBOs.Timing.Time dbo = Mapper.Map <DBOs.Timing.Time>(model); using (IDbConnection conn = Database.Instance.GetConnection()) { conn.Execute("INSERT INTO \"time\" (\"id\", \"start\", \"stop\", \"worker_contact_id\", \"details\", \"billable\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " + "VALUES (@Id, @Start, @Stop, @WorkerContactId, @Details, @Billable, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)", dbo); } return(model); }