Пример #1
0
        public NormalResult UpdateCoupon(Coupon_Info coupon)
        {
            //coupon.modify_date_time = DateTime.Now;

            using (Entities db = new Entities())
            {
                if (db.Coupon_Info.Any(s => s.name == coupon.name && s.id != coupon.id))
                {
                    return(new NormalResult("优惠券名称重复,已被其他优惠券占用。"));
                }

                IQueryable <Coupon_Info> queryable = db.Coupon_Info;

                Coupon_Info dbCoupon_Info = queryable.FirstOrDefault(e => e.id == coupon.id);
                if (dbCoupon_Info == null)
                {
                    return(new NormalResult("指定的数据不存在。"));
                }

                ShengMapper.SetValuesSkipVirtual(coupon, dbCoupon_Info);

                db.SaveChanges();
            }

            return(new NormalResult());
        }
Пример #2
0
        public NormalResult UpdatePointExchange(Point_Exchange pointExchange)
        {
            using (Entities db = new Entities())
            {
                IQueryable <Point_Exchange> queryable = db.Point_Exchange;

                Point_Exchange dbPointExchange = queryable.FirstOrDefault(e => e.id == pointExchange.id);
                if (dbPointExchange == null)
                {
                    return(new NormalResult("指定的数据不存在。"));
                }

                ShengMapper.SetValuesSkipVirtual(pointExchange, dbPointExchange);

                db.SaveChanges();
            }

            return(new NormalResult());
        }
Пример #3
0
        public NormalResult UpdateProductAttribute(Product_Attribute productAttribute)
        {
            using (Entities db = new Entities())
            {
                IQueryable <Product_Attribute> queryable = db.Product_Attribute;

                Product_Attribute dbProduct_Attribute = queryable.FirstOrDefault(e => e.id == productAttribute.id);
                if (dbProduct_Attribute == null)
                {
                    return(new NormalResult("指定的数据不存在。"));
                }

                ShengMapper.SetValuesSkipVirtual(productAttribute, dbProduct_Attribute);

                db.SaveChanges();
            }

            return(new NormalResult());
        }
Пример #4
0
        public NormalResult UpdateMicroClassInfo(Micro_Class_Info microClassInfo)
        {
            microClassInfo.update_time = DateTime.Now;

            using (Entities db = new Entities())
            {
                IQueryable <Micro_Class_Info> queryable = db.Micro_Class_Info;

                Micro_Class_Info dbMicro_Class_Info = queryable.FirstOrDefault(e => e.id == microClassInfo.id);
                if (dbMicro_Class_Info == null)
                {
                    return(new NormalResult("指定的数据不存在。"));
                }

                ShengMapper.SetValuesSkipVirtual(microClassInfo, dbMicro_Class_Info);

                db.SaveChanges();
            }

            return(new NormalResult());
        }
Пример #5
0
        public NormalResult UpdateRole(Role role, List <string> roleAuthorization)
        {
            if (role == null)
            {
                return(new NormalResult("参数错误。"));
            }

            using (Entities db = new Entities())
            {
                if (db.Role.Any(s => s.name == role.name && s.id != role.id))
                {
                    return(new NormalResult("指定的角色名称重复,已被其它角色占用。"));
                }

                Role dbRole = db.Role.FirstOrDefault(s => s.id == role.id);
                if (dbRole == null)
                {
                    return(new NormalResult("指定的数据不存在。"));
                }

                ShengMapper.SetValuesSkipVirtual(role, dbRole);

                dbRole.RoleAuthorization.Clear();

                foreach (var item in roleAuthorization)
                {
                    dbRole.RoleAuthorization.Add(new RoleAuthorization()
                    {
                        roleId           = dbRole.id,
                        authorizationKey = item
                    });
                }

                db.SaveChanges();
            }

            return(new NormalResult());
        }
Пример #6
0
        public NormalResult UpdateProductQRCode(Product_Anti_Fake product)
        {
            using (Entities db = new Entities())
            {
                if (db.Product_Anti_Fake.Any(s => s.product_code == product.product_code && s.id != product.id))
                {
                    return(new NormalResult("商品编码重复,已被其他商品占用。"));
                }

                IQueryable <Product_Anti_Fake> queryable = db.Product_Anti_Fake;

                Product_Anti_Fake dbProduct_Anti_Fake = queryable.FirstOrDefault(e => e.id == product.id);
                if (dbProduct_Anti_Fake == null)
                {
                    return(new NormalResult("指定的数据不存在。"));
                }

                ShengMapper.SetValuesSkipVirtual(product, dbProduct_Anti_Fake);

                db.SaveChanges();
            }

            return(new NormalResult());
        }