Пример #1
0
        public static Common.Models.Activities.ActivityLetter Create(
            Common.Models.Activities.ActivityLetter model,
            Common.Models.Account.Users creator,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            model.CreatedBy = model.ModifiedBy = creator;
            model.Created   = model.Modified = DateTime.UtcNow;
            DBOs.Activities.ActivityLetter dbo = Mapper.Map <DBOs.Activities.ActivityLetter>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            if (conn.Execute("INSERT INTO \"activity_letter\" (\"type\", \"is_campaign_response\", \"subject\", \"body\", \"owner\", \"priority\", \"due\", \"state\", \"status_reason\", " +
                             "\"sender\", \"recipient\", \"direction\", \"duration\", \"address\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                             "VALUES (@Type, @IsCampaignResponse, @Subject, @Body, @Owner, @Priority, @Due, @State, @StatusReason, @Sender, @Recipient, @Direction, @Duration, @Address, " +
                             "@UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                             dbo) > 0)
            {
                model.Id = conn.Query <DBOs.Activities.ActivityLetter>("SELECT currval(pg_get_serial_sequence('activity_base', 'id')) AS \"id\"").Single().Id;
            }

            DataHelper.Close(conn, closeConnection);

            return(model);
        }
Пример #2
0
        public static Common.Models.Activities.ActivityLetter Edit(
            Common.Models.Activities.ActivityLetter model,
            Common.Models.Account.Users modifier,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            model.ModifiedBy = modifier;
            model.Modified   = DateTime.UtcNow;
            DBOs.Activities.ActivityLetter dbo = Mapper.Map <DBOs.Activities.ActivityLetter>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            conn.Execute("UPDATE \"activity_letter\" SET " +
                         "\"type\"=@Type, \"is_campaign_response\"=@IsCampaignResponse, \"subject\"=@Subject, \"body\"=@Body, \"owner\"=@Owner, \"priority\"=@Priority, \"due\"=@Due, " +
                         "\"state\"=@State, \"status_reason\"=@StatusReason, \"sender\"=@Sender, \"recipient\"=@Recipient, \"direction\"=@Direction, \"address\"=@Address, " +
                         "\"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " +
                         "WHERE \"id\"=@Id", dbo);

            DataHelper.Close(conn, closeConnection);

            return(model);
        }