Beispiel #1
0
        public static Common.Models.Notes.NoteNotification Create(Common.Models.Notes.NoteNotification model,
                                                                  Common.Models.Account.Users creator)
        {
            if (!model.Id.HasValue)
            {
                model.Id = Guid.NewGuid();
            }
            model.Created   = model.Modified = DateTime.UtcNow;
            model.CreatedBy = model.ModifiedBy = creator;
            DBOs.Notes.NoteNotification dbo = Mapper.Map <DBOs.Notes.NoteNotification>(model);

            using (IDbConnection conn = Database.Instance.GetConnection())
            {
                Common.Models.Notes.NoteNotification currentModel = Get(model.Note.Id.Value, model.Contact.Id.Value);

                if (currentModel != null)
                { // Update
                    dbo = Mapper.Map <DBOs.Notes.NoteNotification>(currentModel);
                    conn.Execute("UPDATE \"note_notification\" SET \"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId, " +
                                 "\"utc_disabled\"=null, \"disabled_by_user_pid\"=null, \"cleared\"=null WHERE \"id\"=@Id", dbo);
                    model.Created   = currentModel.Created;
                    model.CreatedBy = currentModel.CreatedBy;
                }
                else
                { // Create
                    conn.Execute("INSERT INTO \"note_notification\" (\"id\", \"note_id\", \"contact_id\", \"cleared\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                                 "VALUES (@Id, @NoteId, @ContactId, @Cleared, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                                 dbo);
                }
            }

            return(model);
        }
Beispiel #2
0
        public static Common.Models.Notes.NoteNotification Clear(Common.Models.Notes.NoteNotification model,
                                                                 Common.Models.Account.Users modifier)
        {
            model.Cleared    = DateTime.Now;
            model.ModifiedBy = modifier;
            model.Modified   = DateTime.UtcNow;
            DBOs.Notes.NoteNotification dbo = Mapper.Map <DBOs.Notes.NoteNotification>(model);

            using (IDbConnection conn = Database.Instance.GetConnection())
            {
                conn.Execute("UPDATE \"note_notification\" SET \"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId, " +
                             "\"cleared\"=@Cleared WHERE \"id\"=@Id", dbo);
            }

            return(model);
        }
        public static Common.Models.Notes.NoteNotification Clear(
            Common.Models.Notes.NoteNotification model,
            Common.Models.Account.Users modifier,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            model.Cleared    = DateTime.Now;
            model.ModifiedBy = modifier;
            model.Modified   = DateTime.UtcNow;
            DBOs.Notes.NoteNotification dbo = Mapper.Map <DBOs.Notes.NoteNotification>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            conn.Execute("UPDATE \"note_notification\" SET \"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId, " +
                         "\"cleared\"=@Cleared WHERE \"id\"=@Id", dbo);

            DataHelper.Close(conn, closeConnection);

            return(model);
        }