Esempio n. 1
0
        public static Common.Models.Tasks.TaskTemplate Create(
            Common.Models.Tasks.TaskTemplate model,
            Common.Models.Account.Users creator,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            model.CreatedBy = model.ModifiedBy = creator;
            model.Created   = model.Modified = DateTime.UtcNow;
            DBOs.Tasks.TaskTemplate dbo = Mapper.Map <DBOs.Tasks.TaskTemplate>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            if (conn.Execute("INSERT INTO \"task_template\" (\"task_template_title\", \"title\", \"description\", \"projected_start\", \"due_date\", \"projected_end\", " +
                             "\"actual_end\", \"active\", \"utc_created\", " +
                             "\"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                             "VALUES (@TaskTemplateTitle, @Title, @Description, @ProjectedStart, @DueDate, @ProjectedEnd, @ActualEnd, " +
                             "@Active, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                             dbo) > 0)
            {
                model.Id = conn.Query <DBOs.Tasks.TaskTemplate>("SELECT currval(pg_get_serial_sequence('task_template', 'id')) AS \"id\"").Single().Id;
            }

            DataHelper.Close(conn, closeConnection);

            return(model);
        }
Esempio n. 2
0
        public static Common.Models.Tasks.TaskTemplate Edit(
            Common.Models.Tasks.TaskTemplate model,
            Common.Models.Account.Users modifier,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            model.ModifiedBy = modifier;
            model.Modified   = DateTime.UtcNow;
            DBOs.Tasks.TaskTemplate dbo = Mapper.Map <DBOs.Tasks.TaskTemplate>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            conn.Execute("UPDATE \"task_template\" SET \"task_template_title\"=@TaskTemplateTitle, " +
                         "\"title\"=@Title, \"description\"=@Description, \"projected_start\"=@ProjectedStart, " +
                         "\"due_date\"=@DueDate, \"projected_end\"=@ProjectedEnd, \"actual_end\"=@ActualEnd, " +
                         "\"active\"=@Active, \"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " +
                         "WHERE \"id\"=@Id", dbo);

            DataHelper.Close(conn, closeConnection);

            //if (model.Parent != null && model.Parent.Id.HasValue)
            //    UpdateGroupingTaskProperties(OpenLawOffice.Data.Tasks.Task.Get(model.Parent.Id.Value));

            return(model);
        }