Esempio n. 1
0
        internal static InvoiceInfo FetchInvoiceInfo(Data.Invoice data)
        {
            var result = new InvoiceInfo();

            result.Fetch(data);
            return(result);
        }
Esempio n. 2
0
        protected void Insert(Data.Invoice data)
        {
            data.InvoiceId   = this.ReadProperty(InvoiceIdProperty);
            data.CreatedBy   = ((BusinessIdentity)Csla.ApplicationContext.User.Identity).UserId;
            data.CreatedDate = DateTime.Now;

            this.Update(data);
        }
Esempio n. 3
0
        protected override void DataPortal_DeleteSelf()
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Invoice
                {
                    InvoiceId = this.ReadProperty(InvoiceIdProperty)
                };

                ctx.ObjectContext.Invoices.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
Esempio n. 4
0
 protected void Update(Data.Invoice data)
 {
     if (this.IsSelfDirty)
     {
         data.Number       = this.ReadProperty(NumberProperty);
         data.TaskId       = this.ReadProperty(TaskIdProperty);
         data.PreparedDate = this.ReadProperty(PreparedDateProperty);
         data.Description  = this.ReadProperty(DescriptionProperty);
         data.Amount       = this.ReadProperty(AmountProperty);
         data.IsArchived   = this.ReadProperty(IsArchivedProperty);
         data.Notes        = this.ReadProperty(NotesProperty);
         data.ModifiedBy   = ((BusinessIdentity)Csla.ApplicationContext.User.Identity).UserId;
         data.ModifiedDate = DateTime.Now;
     }
 }
Esempio n. 5
0
        protected override void DataPortal_DeleteSelf()
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Invoice
                {
                    InvoiceId = this.ReadProperty(InvoiceIdProperty)
                };

                ctx.ObjectContext.Invoices.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
Esempio n. 6
0
        protected override void DataPortal_Insert()
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Invoice();

                this.Insert(data);

                ctx.ObjectContext.AddToInvoices(data);

                ctx.ObjectContext.SaveChanges();

                this.LoadProperty(InvoiceIdProperty, data.InvoiceId);
                this.LoadProperty(CreatedByProperty, data.CreatedBy);
                this.LoadProperty(CreatedDateProperty, data.CreatedDate);
            }
        }
Esempio n. 7
0
        protected override void DataPortal_Insert()
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Invoice();

                this.Insert(data);

                ctx.ObjectContext.AddToInvoices(data);

                ctx.ObjectContext.SaveChanges();

                this.LoadProperty(InvoiceIdProperty, data.InvoiceId);
                this.LoadProperty(CreatedByProperty, data.CreatedBy);
                this.LoadProperty(CreatedDateProperty, data.CreatedDate);
            }
        }
Esempio n. 8
0
 protected void Fetch(Data.Invoice data)
 {
     this.LoadProperty(InvoiceIdProperty, data.InvoiceId);
     this.LoadProperty(NumberProperty, data.Number);
     this.LoadProperty(ProjectIdProperty, data.Task.ProjectId);
     this.LoadProperty(ProjectNameProperty, data.Task.Project.Name);
     this.LoadProperty(DescriptionProperty, data.Description);
     this.LoadProperty(TaskIdProperty, data.TaskId);
     this.LoadProperty(PreparedDateProperty, data.PreparedDate);
     this.LoadProperty(AmountProperty, data.Amount);
     this.LoadProperty(IsArchivedProperty, data.IsArchived);
     this.LoadProperty(NotesProperty, data.Notes);
     this.LoadProperty(ModifiedByProperty, data.ModifiedBy);
     this.LoadProperty(ModifiedByNameProperty, data.ModifiedByUser.Name);
     this.LoadProperty(ModifiedDateProperty, data.ModifiedDate);
     this.LoadProperty(CreatedByProperty, data.CreatedBy);
     this.LoadProperty(CreatedByNameProperty, data.CreatedByUser.Name);
     this.LoadProperty(CreatedDateProperty, data.CreatedDate);
 }
Esempio n. 9
0
        protected override void DataPortal_Update()
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Invoice
                {
                    InvoiceId = this.ReadProperty(InvoiceIdProperty)
                };

                ctx.ObjectContext.Invoices.Attach(data);

                this.Update(data);

                ctx.ObjectContext.SaveChanges();

                this.LoadProperty(ModifiedByProperty, data.ModifiedBy);
                this.LoadProperty(ModifiedDateProperty, data.ModifiedDate);
            }
        }
Esempio n. 10
0
        protected override void DataPortal_Update()
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Invoice
                {
                    InvoiceId = this.ReadProperty(InvoiceIdProperty)
                };

                ctx.ObjectContext.Invoices.Attach(data);

                this.Update(data);

                ctx.ObjectContext.SaveChanges();

                this.LoadProperty(ModifiedByProperty, data.ModifiedBy);
                this.LoadProperty(ModifiedDateProperty, data.ModifiedDate);
            }
        }
Esempio n. 11
0
        public JsonResult Create(string Tablename, int ClientId, List<string[]> TableValue, string[] ColumnName, string[] ColumnValue )
        {
            string msg = "Data Saved";
            var ListData = new List<InvoiceData>();

            if (ColumnName.Length != ColumnValue.Length)
            {
                msg = "Missing Values";
            }
            else
            {
                var invoice = new Data.Invoice()
                {
                    Client_Id = ClientId,
                    Payment_Status = false,
                };

                foreach (var l in TableValue)
                    ListData.Add(new Data.InvoiceData()
                    {
                        Invoice = invoice,
                        Description = l[0],
                        Labor = decimal.Parse(l[1]),
                        Tax = decimal.Parse(l[2]),
                        Total = decimal.Parse(l[3])
                    });

                foreach (var i in ListData)
                {
                    DataService.InvoiceData.Add(i);
                }

                DataService.Invoice.Add(invoice);

                try
                {
                    StringBuilder query = new StringBuilder("INSERT INTO [" + Tablename + "] (Id, ");

                    int i = 0;
                    for (; i < ColumnName.Length - 1; i++)
                    {
                        query.AppendFormat("[{0}], ", ColumnName[i]);
                    }
                    query.AppendFormat("[{0}]) VALUES ({1}, ", ColumnName[i], ClientId);

                    for (i=0; i < ColumnValue.Length - 1; i++)
                    {
                        query.AppendFormat("'{0}', ", ColumnValue[i]);
                    }
                    query.AppendFormat("'{0}')", ColumnValue[i]);

                    DataService.DataContext.Database.ExecuteSqlCommand(query.ToString());
                }
                catch (Exception e)
                {
                    DataService.Invoice.Delete(invoice);

                    foreach(var i in ListData)
                        DataService.InvoiceData.Delete(i);

                    msg = e.Message;
                    Console.Write(msg);
                }

            }
            return new JsonResult() { Data = new { message = msg} };
        }