Ejemplo n.º 1
0
partial         void OnPreInsertEmailMessage(IUnitOfWorkContext unitOfWorkContext, EmailMessage emailMessage)
        {
            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            if ((object)emailMessage == null)
                throw new ArgumentNullException("emailMessage");

            //emailMessage.Mark();
        }
Ejemplo n.º 2
0
        public bool DiscardEmailMessage(IUnitOfWorkContext unitOfWorkContext, EmailMessage @emailMessage)
        {
            TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailMessage query;

            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            if ((object)@emailMessage == null)
                throw new ArgumentNullException("emailMessage");

            if (@emailMessage.IsNew)
                return true;

            using (ContextWrapper<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext> ctx = unitOfWorkContext.GetContext<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext>())
            {
                this.OnPreDeleteEmailMessage(unitOfWorkContext, @emailMessage);

                query = [email protected](lo => lo.@EmailMessageId == @emailMessage.@EmailMessageId);

                if((object)query == null)
                    throw new InvalidOperationException("TODO (enhancement): add meaningful message");

                [email protected](query);

                try
                {
                    ctx.Context.SubmitChanges(ConflictMode.FailOnFirstConflict);
                }
                catch (ChangeConflictException ccex)
                {
                    this.OnDiscardConflictEmailMessage(unitOfWorkContext, @emailMessage);

                    return false;
                }

                this.OnPostDeleteEmailMessage(unitOfWorkContext, @emailMessage);

                @emailMessage.IsNew = false;

                return true;
            }
        }
Ejemplo n.º 3
0
        public bool DiscardEmailMessage(EmailMessage @emailMessage)
        {
            bool retval;

            retval = Ambient.ExecuteAmbientUnitOfWorkAware(Repository.UowcFactory.Instance, (uowc, e) => this.DiscardEmailMessage(uowc, e), @emailMessage);

            return retval;
        }
Ejemplo n.º 4
0
partial         void OnSelectEmailMessage(IUnitOfWorkContext unitOfWorkContext, EmailMessage @emailMessage);
Ejemplo n.º 5
0
partial         void OnSaveConflictEmailMessage(IUnitOfWorkContext unitOfWorkContext, EmailMessage @emailMessage);
Ejemplo n.º 6
0
partial         void OnPreUpdateEmailMessage(IUnitOfWorkContext unitOfWorkContext, EmailMessage @emailMessage);
Ejemplo n.º 7
0
partial         void OnPreInsertEmailMessage(IUnitOfWorkContext unitOfWorkContext, EmailMessage @emailMessage);
Ejemplo n.º 8
0
partial         void OnPostDeleteEmailMessage(IUnitOfWorkContext unitOfWorkContext, EmailMessage @emailMessage);
Ejemplo n.º 9
0
partial         void OnDiscardConflictEmailMessage(IUnitOfWorkContext unitOfWorkContext, EmailMessage @emailMessage);
Ejemplo n.º 10
0
        public bool SaveEmailMessage(IUnitOfWorkContext unitOfWorkContext, EmailMessage @emailMessage)
        {
            TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailMessage query;
            bool wasNew;

            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            if ((object)@emailMessage == null)
                throw new ArgumentNullException("emailMessage");

            using (ContextWrapper<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext> ctx = unitOfWorkContext.GetContext<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext>())
            {
                wasNew = @emailMessage.IsNew;

                if (wasNew)
                {
                    this.OnPreInsertEmailMessage(unitOfWorkContext, @emailMessage);

                    query = new TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailMessage();

                    ctx.Context.EmailMessages.InsertOnSubmit(query);
                }
                else
                {
                    this.OnPreUpdateEmailMessage(unitOfWorkContext, @emailMessage);

                    query = ctx.Context.EmailMessages.SingleOrDefault(lo => lo.@EmailMessageId == @emailMessage.@EmailMessageId);

                    if((object)query == null)
                        throw new InvalidOperationException("TODO (enhancement): add meaningful message");
                }

                // map caller POCO changes to L2S object
                query.@EmailMessageId = @emailMessage.@EmailMessageId;
                query.@From = @emailMessage.@From;
                query.@Sender = @emailMessage.@Sender;
                query.@ReplyTo = @emailMessage.@ReplyTo;
                query.@To = @emailMessage.@To;
                query.@Cc = @emailMessage.@Cc;
                query.@Bcc = @emailMessage.@Bcc;
                query.@Subject = @emailMessage.@Subject;
                query.@IsBodyHtml = @emailMessage.@IsBodyHtml;
                query.@Body = @emailMessage.@Body;
                query.@Processed = @emailMessage.@Processed;
                query.@CreationTimestamp = @emailMessage.@CreationTimestamp;
                query.@ModificationTimestamp = @emailMessage.@ModificationTimestamp;
                query.@LogicalDelete = @emailMessage.@LogicalDelete;

                try
                {
                    ctx.Context.SubmitChanges(ConflictMode.FailOnFirstConflict);
                }
                catch (ChangeConflictException ccex)
                {
                    this.OnSaveConflictEmailMessage(unitOfWorkContext, @emailMessage);

                    return false;
                }

                // map server changes back to POCO from L2S object
                @emailMessage.@EmailMessageId = query.@EmailMessageId;
                @emailMessage.@From = query.@From;
                @emailMessage.@Sender = query.@Sender;
                @emailMessage.@ReplyTo = query.@ReplyTo;
                @emailMessage.@To = query.@To;
                @emailMessage.@Cc = query.@Cc;
                @emailMessage.@Bcc = query.@Bcc;
                @emailMessage.@Subject = query.@Subject;
                @emailMessage.@IsBodyHtml = query.@IsBodyHtml;
                @emailMessage.@Body = query.@Body;
                @emailMessage.@Processed = query.@Processed;
                @emailMessage.@CreationTimestamp = query.@CreationTimestamp;
                @emailMessage.@ModificationTimestamp = query.@ModificationTimestamp;
                @emailMessage.@LogicalDelete = query.@LogicalDelete;

                if (wasNew)
                {
                    this.OnPostInsertEmailMessage(unitOfWorkContext, @emailMessage);
                }
                else
                {
                    this.OnPostUpdateEmailMessage(unitOfWorkContext, @emailMessage);
                }

                return true;
            }
        }
Ejemplo n.º 11
0
        public EmailMessage LoadEmailMessage(IUnitOfWorkContext unitOfWorkContext, Int32 @emailMessageId)
        {
            EmailMessage @emailMessage;
            TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailMessage query;

            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            using (ContextWrapper<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext> ctx = unitOfWorkContext.GetContext<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext>())
            {
                query = ctx.Context.EmailMessages.SingleOrDefault(lo => lo.@EmailMessageId == @emailMessageId);

                if ((object)query == null)
                    return null; // does not exist

                @emailMessage = new EmailMessage()
                                {
                                    // map result to POCO from L2S object
                                    @EmailMessageId = query.@EmailMessageId,
                                    @From = query.@From,
                                    @Sender = query.@Sender,
                                    @ReplyTo = query.@ReplyTo,
                                    @To = query.@To,
                                    @Cc = query.@Cc,
                                    @Bcc = query.@Bcc,
                                    @Subject = query.@Subject,
                                    @IsBodyHtml = query.@IsBodyHtml,
                                    @Body = query.@Body,
                                    @Processed = query.@Processed,
                                    @CreationTimestamp = query.@CreationTimestamp,
                                    @ModificationTimestamp = query.@ModificationTimestamp,
                                    @LogicalDelete = query.@LogicalDelete
                                };

                this.OnSelectEmailMessage(unitOfWorkContext, @emailMessage);

                return @emailMessage;
            }
        }