示例#1
0
        public Guid Update(Model.Transaction tranEntity)
        {
            var context = new CMS_DataContext();
            var trans   = context.Transactions.Where(x => x.Id == tranEntity.Id).FirstOrDefault();

            trans.Reference       = tranEntity.Reference;
            trans.Amount          = tranEntity.Amount;
            trans.Notes           = tranEntity.Notes;
            trans.CreditAccountId = tranEntity.CreditAccount.Id;
            trans.DebitAccountId  = tranEntity.DebitAccount.Id;
            trans.Date            = DateTime.Parse(tranEntity.Date);

            context.SubmitChanges();
            return(tranEntity.Id);
        }
示例#2
0
        public Guid Create(Model.Transaction transEntity)
        {
            var context = new CMS_DataContext();
            var trans   = new DataAccess.Transaction()
            {
                Id              = transEntity.Id,
                Reference       = transEntity.Reference,
                Notes           = transEntity.Notes,
                CreditAccountId = transEntity.CreditAccount.Id,
                DebitAccountId  = transEntity.DebitAccount.Id,
                Amount          = transEntity.Amount,
                Date            = DateTime.Parse(transEntity.Date)
            };


            try
            {
                context.Transactions.InsertOnSubmit(trans);
                context.SubmitChanges();
            }
            catch (Exception ex)
            { throw ex; }
            return(transEntity.Id);
        }