Esempio n. 1
0
        /// <summary>
        /// 查找活动和奖品情况
        /// </summary>
        /// <param name="unid"></param>
        /// <returns></returns>
        public Domain.DinnerShop.Update Find_DinnerShop(string unid)
        {
            if (!unid.IsNotNullOrEmpty())
            {
                return(null);
            }
            using (DbRepository entities = new DbRepository())
            {
                Domain.DinnerShop.Update model = new Domain.DinnerShop.Update();

                var entity       = entities.DinnerShop.Find(unid);
                var personEntity = entities.Person.Where(x => x.UNID.Equals(entity.PersonId)).FirstOrDefault();
                if (entity != null)
                {
                    entity.AutoMap <DinnerShop, Domain.DinnerShop.Update>(model);
                }
                else
                {
                    return(null);
                }
                if (personEntity != null)
                {
                    model.Account = personEntity.Account;
                }
                else
                {
                    return(null);
                }
                return(model);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string Add_DinnerShop(Domain.DinnerShop.Update model)
        {
            if (model == null ||
                !model.Name.IsNotNullOrEmpty() ||
                !model.Account.IsNotNullOrEmpty()
                )
            {
                return("数据为空");
            }
            using (DbRepository entities = new DbRepository())
            {
                var query = entities.DinnerShop.AsQueryable();
                if (query.Where(x => x.Name.Equals(model.Name) && ((x.Flag & (long)GlobalFlag.Removed) != 0)).Count() != 0)
                {
                    return("店铺名称已存在");
                }

                if (entities.Person.Where(x => x.Account.Equals(model.Account)).Count() != 0)
                {
                    return("店铺登陆账号已存在");
                }
                string password = Core.Util.CryptoHelper.MD5_Encrypt(model.Password);

                var addEntity = model.AutoMap <Domain.DinnerShop.Update, DinnerShop>();
                addEntity.UNID = Guid.NewGuid().ToString("N");

                var addPerson = new Person()
                {
                    UNID        = Guid.NewGuid().ToString("N"),
                    Account     = model.Account,
                    CreatedTime = DateTime.Now,
                    UpdatedTime = DateTime.Now,
                    Flag        = (long)GlobalFlag.Normal,
                    Password    = password,
                    Remark      = "店铺",
                    IsChildren  = (int)YesOrNoCode.Yes,
                    ShopId      = addEntity.UNID,
                    Name        = model.Name
                };

                addEntity.Name        = model.Name;
                addEntity.CreatedTime = DateTime.Now;
                addEntity.UpdatedTime = DateTime.Now;
                addEntity.Flag        = (long)GlobalFlag.Normal;
                addEntity.PersonId    = this.Client.LoginUser.UNID;


                entities.DinnerShop.Add(addEntity);
                entities.Person.Add(addPerson);
                return(entities.SaveChanges() > 0 ? "" : "保存出错");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 增加刮刮卡
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string Update_DinnerShop(Domain.DinnerShop.Update model, string unid)
        {
            if (model == null ||
                !model.Name.IsNotNullOrEmpty() ||
                !model.Account.IsNotNullOrEmpty()
                )
            {
                return("数据为空");
            }
            using (DbRepository entities = new DbRepository())
            {
                var oldEntity = entities.DinnerShop.Find(unid);
                if (oldEntity != null)
                {
                    var query = entities.DinnerShop.AsQueryable();
                    if (query.Where(x => x.Name.Equals(model.Name) && !x.UNID.Equals(unid) && ((x.Flag & (long)GlobalFlag.Removed) != 0)).Count() != 0)
                    {
                        return("店铺名称已存在");
                    }

                    var personEntity = entities.Person.Where(x => x.UNID.Equals(oldEntity.PersonId) && ((x.Flag & (long)GlobalFlag.Removed) != 0)).FirstOrDefault();
                    if (personEntity == null)
                    {
                        return("店铺登陆账号不存在");
                    }
                    string password = Core.Util.CryptoHelper.MD5_Encrypt(model.Password);
                    if (personEntity.Account != model.Account || personEntity.Password != password)
                    {
                        if (entities.Person.Where(x => x.Account.Equals(model.Account) && !x.UNID.Equals(oldEntity.PersonId) && ((x.Flag & (long)GlobalFlag.Removed) != 0)).Count() != 0)
                        {
                            return("账号已存在");
                        }
                        personEntity.Account = model.Account;
                        if (!string.IsNullOrEmpty(model.Password))
                        {
                            personEntity.Password = password;
                        }
                    }

                    model.AutoMap <Domain.DinnerShop.Update, DinnerShop>(oldEntity);
                    oldEntity.UpdatedTime = DateTime.Now;
                }
                else
                {
                    return("数据为空");
                }

                return(entities.SaveChanges() > 0 ? "" : "保存出错");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"</param>
        /// <returns></returns>
        public JsonResult Update(Domain.DinnerShop.Update model, string unid)
        {
            var result = IDinnerShopService.Update_DinnerShop(model, unid);

            return(JResult(result));
        }
Esempio n. 5
0
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="model"</param>
        /// <returns></returns>
        public JsonResult Add(Domain.DinnerShop.Update model)
        {
            var result = IDinnerShopService.Add_DinnerShop(model);

            return(JResult(result));
        }