Ejemplo n.º 1
0
        internal static TBiz SaveAsUser <TBiz, TDal>(TBiz item, int userId)
            where TDal : D.EntityObject, IQpEntityObject
            where TBiz : EntityObject
        {
            var entities = QPContext.EFContext;
            var dalItem  = DefaultMapper.GetDalObject <TDal, TBiz>(item);

            if (item.ForceId != 0)
            {
                dalItem.Id = item.ForceId;
            }

            DateTime current;

            using (new QPConnectionScope())
            {
                current = Common.GetSqlDate(QPConnectionScope.Current.DbConnection);
            }

            dalItem.Created        = current;
            dalItem.Modified       = current;
            dalItem.LastModifiedBy = userId;
            entities.AddObject(GetSetNameByType(typeof(TDal)), dalItem);
            entities.SaveChanges();

            return(DefaultMapper.GetBizObject <TBiz, TDal>(dalItem));
        }
Ejemplo n.º 2
0
        internal static TBiz Update <TBiz, TDal>(TBiz item)
            where TDal : class, IQpEntityObject
            where TBiz : EntityObject
        {
            var dalItem  = DefaultMapper.GetDalObject <TDal, TBiz>(item);
            var entities = QPContext.EFContext;

            dalItem.LastModifiedBy = QPContext.CurrentUserId;

            using (new QPConnectionScope())
            {
                dalItem.Modified = Common.GetSqlDate(QPConnectionScope.Current.DbConnection);
            }

            entities.Entry(dalItem).State = EntityState.Modified;
            entities.SaveChanges();
            return(DefaultMapper.GetBizObject <TBiz, TDal>(dalItem));
        }
Ejemplo n.º 3
0
        internal static TBiz Update <TBiz, TDal>(TBiz item)
            where TDal : D.EntityObject, IQpEntityObject
            where TBiz : EntityObject
        {
            var dalItem  = DefaultMapper.GetDalObject <TDal, TBiz>(item);
            var entities = QPContext.EFContext;

            dalItem.LastModifiedBy = QPContext.CurrentUserId;

            using (new QPConnectionScope())
            {
                dalItem.Modified = Common.GetSqlDate(QPConnectionScope.Current.DbConnection);
            }

            entities.AttachTo(GetSetNameByType(typeof(TDal)), dalItem);
            entities.ObjectStateManager.ChangeObjectState(dalItem, EntityState.Modified);
            entities.SaveChanges();
            return(DefaultMapper.GetBizObject <TBiz, TDal>(dalItem));
        }
Ejemplo n.º 4
0
        internal static NetLanguage GetNetLanguageById(int id)
        {
            var entities = QPContext.EFContext;

            return(DefaultMapper.GetBizObject <NetLanguage, NetLanguagesDAL>(entities.NetLanguagesSet.SingleOrDefault(x => x.Id == id)));
        }
Ejemplo n.º 5
0
        internal static NetLanguage GetNetLanguageByName(string name)
        {
            var entities = QPContext.EFContext;

            return(DefaultMapper.GetBizObject <NetLanguage, NetLanguagesDAL>(entities.NetLanguagesSet.SingleOrDefault(x => x.Name == name)));
        }