Beispiel #1
0
        public bool Update(TarfeHesab tarfeHesab)
        {
            try
            {
                var local = _uow.Set <TarfeHesab>()
                            .Local
                            .FirstOrDefault(f => f.ID == tarfeHesab.ID);
                if (local != null)
                {
                    _uow.Entry(local).State = EntityState.Detached;
                }

                var local2 = _uow.Set <Person>()
                             .Local
                             .FirstOrDefault(f => f.ID == tarfeHesab.Person.ID);
                if (local2 != null)
                {
                    _uow.Entry(local2).State = EntityState.Detached;
                }
                var local3 = _uow.Set <Bank>()
                             .Local
                             .FirstOrDefault(f => f.ID == tarfeHesab.Bank.ID);
                if (local3 != null)
                {
                    _uow.Entry(local3).State = EntityState.Detached;
                }


                _tarfeHesabs.Attach(tarfeHesab);

                if (tarfeHesab.Person.ID > 0)
                {
                    _uow.Entry(tarfeHesab.Person).State = EntityState.Modified;
                }
                else if (tarfeHesab.Person != null)
                {
                    _uow.Entry(tarfeHesab.Person).State = EntityState.Added;
                }

                if (tarfeHesab.Bank != null && tarfeHesab.Bank.ID > 0)
                {
                    _uow.Entry(tarfeHesab.Bank).State = EntityState.Modified;
                }
                else if (tarfeHesab.Bank != null)
                {
                    _uow.Entry(tarfeHesab.Bank).State = EntityState.Added;
                }

                _uow.Entry(tarfeHesab).State = EntityState.Modified;


                //_uow.Entry(tarfeHesab).Property(p => p.CreatedOn).IsModified = false;
                //_uow.Entry(tarfeHesab).Property(p => p.CreatedBy).IsModified = false;
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Beispiel #2
0
        public bool Insert(TarfeHesab tarfeHesab)
        {
            try
            {
                if (string.IsNullOrEmpty(tarfeHesab.Bank.Name))
                {
                    tarfeHesab.Bank = null;
                }

                _tarfeHesabs.Add(tarfeHesab);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #3
0
        public bool Delete(TarfeHesab tarfeHesab)
        {
            try
            {
                _tarfeHesabs.Attach(tarfeHesab);

                _uow.Entry(tarfeHesab.Bank).State = EntityState.Deleted;

                _tarfeHesabs.Remove(tarfeHesab);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }