コード例 #1
0
        public void Update(DonorGivingModel donorGiving)
        {
            if (!UpdateDatabase)
            {
                var target = One(e => e.DonorGivingID == donorGiving.DonorGivingID);

                if (target != null)
                {
                    target.DonorGivingID = donorGiving.DonorGivingID;
                    target.DonorID       = donorGiving.DonorID;
                    target.AmountGiven   = donorGiving.AmountGiven;
                    target.DateGiven     = donorGiving.DateGiven;
                    target.InKind        = donorGiving.InKind;
                    target.IsDeleted     = donorGiving.IsDeleted;
                }
            }
            else
            {
                var entity = new DonorGiving();

                entity.DonorGivingID = donorGiving.DonorGivingID;
                entity.DonorID       = donorGiving.DonorID;
                entity.AmountGiven   = donorGiving.AmountGiven;
                entity.DateGiven     = donorGiving.DateGiven;
                entity.InKind        = donorGiving.InKind;
                entity.IsDeleted     = donorGiving.IsDeleted;

                entities.DonorGivings.Attach(entity);
                entities.Entry(entity).State = EntityState.Modified;
                entities.SaveChanges();
            }
        }
コード例 #2
0
        public void Create(DonorGivingModel donorGiving)
        {
            if (!UpdateDatabase)
            {
                var first = GetAll().OrderByDescending(e => e.DonorGivingID).FirstOrDefault();
                var id    = (first != null) ? first.DonorGivingID : 0;

                GetAll().Insert(0, donorGiving);
            }
            else
            {
                var entity = new DonorGiving();

                entity.DonorGivingID = donorGiving.DonorGivingID;
                entity.DonorID       = donorGiving.DonorID;
                entity.AmountGiven   = donorGiving.AmountGiven;
                entity.DateGiven     = donorGiving.DateGiven;
                entity.InKind        = donorGiving.InKind;
                entity.IsDeleted     = donorGiving.IsDeleted;

                entities.DonorGivings.Add(entity);
                entities.SaveChanges();

                donorGiving.DonorGivingID = entity.DonorGivingID;
            }
        }