示例#1
0
        public virtual void Delete(T t)
        {
            if (context.Entry(t).State == System.Data.Entity.EntityState.Detached)
            {
                DbSet.Attach(t);
            }

            DbSet.Remove(t);

            context.SaveChanges();
        }
示例#2
0
        public void UpdateUserRecord(UserModel model)
        {
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
            {
                User result = DB.Users.FirstOrDefault(u => u.UserId == model.UserId);

                if (result != null)
                {
                    result.RoleId       = model.RoleId;
                    result.DesgId       = model.DesignationId;
                    result.OfficeId     = model.OfficeId;
                    result.Username     = model.Username ?? result.Username;
                    result.LoginId      = model.LoginId ?? result.LoginId;
                    result.UpdatedDate  = model.UpdatedDate;
                    result.IsActive     = model.IsActive;
                    result.EmailAddress = model.EmailAddress;
                }

                DB.Entry(result).CurrentValues.SetValues(result);
                DB.SaveChanges();
                ts.Complete();
            }
        }
示例#3
0
        public void UpdateFiscalYearRecord(FiscalYearModel model)
        {
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
            {
                var fiscalYear = Db.FiscalYears.FirstOrDefault(x => x.Id == model.Id);

                if (fiscalYear != null)
                {
                    fiscalYear.FiscalYearName    = model.FiscalYearName ?? fiscalYear.FiscalYearName;
                    fiscalYear.CreatedDate       = model.CreatedDate ?? fiscalYear.CreatedDate;
                    fiscalYear.UpdatedDate       = model.UpdatedDate ?? fiscalYear.UpdatedDate;
                    fiscalYear.StartDate         = model.StartDate;
                    fiscalYear.EndDate           = model.EndDate;
                    fiscalYear.StartDateNp       = model.StartDateNp ?? fiscalYear.StartDateNp;
                    fiscalYear.EndDateNp         = model.EndDateNp ?? fiscalYear.EndDateNp;
                    fiscalYear.CurrentFiscalYear = model.CurrentFiscalYear;
                }

                Db.Entry(fiscalYear).CurrentValues.SetValues(fiscalYear);
                Db.SaveChanges();

                ts.Complete();
            }
        }