Пример #1
0
 /// <summary>
 /// 填写用户信息
 /// </summary>
 /// <param name="userInfo"></param>
 /// <returns></returns>
 public long AddUserInfo(UserInfoDTO userInfo)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <CardTypeEntity> cardType
             = new BaseService <CardTypeEntity>(ctx);
         UserInfoEntity userInfoEntity = new UserInfoEntity();
         userInfoEntity.Address      = userInfo.Address;
         userInfoEntity.Email        = userInfo.Email;
         userInfoEntity.Gender       = userInfo.Gender;
         userInfoEntity.IDCardNo     = userInfo.IDCardNo;
         userInfoEntity.Money        = userInfo.Money;
         userInfoEntity.PassAnswer   = userInfo.PassAnswer;
         userInfoEntity.PassQuestion = userInfo.PassQuestion;
         string salt = CommomHelper.CreateVerifyCode(5);
         string hash = CommomHelper.CalcMD5(salt + userInfo.Password);
         userInfoEntity.PassWordSalt = salt;
         userInfoEntity.PassWordHash = hash;
         userInfoEntity.PhoneNumber  = userInfo.PhoneNumber;
         userInfoEntity.RoleInfoId   = userInfo.RoleId;
         userInfoEntity.UserName     = userInfo.UserName;
         userInfoEntity.UserStateId  = userInfo.UserStateId;
         foreach (var item in cardType.GetAll().Where(a => userInfo.CardTypeIds.Contains(a.Id)))
         {
             userInfoEntity.CardTypes.Add(item);
         }
         ctx.UserInfos.Add(userInfoEntity);
         ctx.SaveChanges();
         return(userInfoEntity.Id);
     }
 }
Пример #2
0
 /// <summary>
 /// 更新用户信息
 /// </summary>
 /// <param name="userInfo"></param>
 /// <returns></returns>
 public long UpdateUserInfo(UserInfoDTO userInfo)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <UserInfoEntity> bs = new BaseService <UserInfoEntity>(ctx);
         var dbUser = bs.GetById(userInfo.Id);
         dbUser.Address      = userInfo.Address;
         dbUser.Email        = userInfo.Email;
         dbUser.Gender       = userInfo.Gender;
         dbUser.IDCardNo     = userInfo.IDCardNo;
         dbUser.Money        = userInfo.Money;
         dbUser.PassQuestion = userInfo.PassQuestion;
         dbUser.PassAnswer   = userInfo.PassAnswer;
         dbUser.PhoneNumber  = userInfo.PhoneNumber;
         dbUser.RoleInfoId   = userInfo.RoleId;
         dbUser.UserStateId  = userInfo.UserStateId;
         dbUser.UserName     = userInfo.UserName;
         string hash = CommomHelper.CalcMD5(dbUser.PassWordSalt + userInfo.Password);
         dbUser.PassWordHash = hash;
         dbUser.CardTypes.Clear();
         var atts = ctx.CardType.Where(a => a.IsDelete == false &&
                                       userInfo.CardTypeIds.Contains(a.Id));
         foreach (var item in atts)
         {
             dbUser.CardTypes.Add(item);
         }
         ctx.SaveChanges();
         return(dbUser.Id);
     }
 }
Пример #3
0
 /// <summary>
 /// 获取指定用户id的所有Advice
 /// </summary>
 /// <param name="t_userId"></param>
 /// <returns></returns>
 public AdviceDTO[] GetAllAdviceByUserId(long t_userId)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <AdviceEntity> bs = new BaseService <AdviceEntity>(ctx);
         var users = bs
                     .GetAll()
                     .Include(e => e.User)
                     .Where(e => e.UserId == t_userId)
                     .AsNoTracking()
                     .ToList();
         List <AdviceDTO> adviceDTOs = new List <AdviceDTO>();
         foreach (var item in users)
         {
             AdviceDTO adviceDTO = new AdviceDTO()
             {
                 Id             = item.Id,
                 Content        = item.Content,
                 CreateDateTime = item.CreateDateTime,
                 UserId         = item.UserId,
                 UserName       = item.User.UserName
             };
             adviceDTOs.Add(adviceDTO);
         }
         return(adviceDTOs.ToArray());
     }
 }
Пример #4
0
 public long UpdateCardType(CardTypeDTO t_CardType)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <CardTypeEntity> cardTypebs = new BaseService <CardTypeEntity>(ctx);
         BaseService <UserInfoEntity> bs         = new BaseService <UserInfoEntity>(ctx);
         if (cardTypebs.GetById(t_CardType.Id) != null)
         {
             CardTypeEntity cardTypeEntity = new CardTypeEntity();
             cardTypeEntity.CardImage    = t_CardType.CardImage;
             cardTypeEntity.CardPrice    = t_CardType.CardPrice;
             cardTypeEntity.CardTypeName = t_CardType.CardTypeName;
             foreach (var item in bs.GetAll().Where(a => t_CardType.UserInfoIds.Contains(a.Id)))
             {
                 cardTypeEntity.UserInfos.Add(item);
             }
             ctx.SaveChanges();
             return(cardTypeEntity.Id);
         }
         else
         {
             return(0);
         }
     }
 }
Пример #5
0
 /// <summary>
 /// 指定id软删除
 /// </summary>
 /// <param name="t_newsId"></param>
 /// <returns></returns>
 public void DeleteNew(long t_newsId)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <NewsEntity> bs = new BaseService <NewsEntity>(ctx);
         bs.MarkDeleted(t_newsId);
     }
 }
Пример #6
0
 /// <summary>
 /// 根据Id软删除
 /// </summary>
 /// <param name="t_adviceId"></param>
 public void DeleteAdvice(long t_adviceId)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <AdviceEntity> bs = new BaseService <AdviceEntity>(ctx);
         bs.MarkDeleted(t_adviceId);
     }
 }
Пример #7
0
 public PostHistoryDTO[] GetAllPostHistory()
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <PostHistoryEntity> bs = new BaseService <PostHistoryEntity>(ctx);
         return(bs.GetAll().Select(e => ToDTO(e)).ToArray());
     }
 }
Пример #8
0
 public PostFailedInfoDTO[] GetAllPostFailedInfo()
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <PostFailedInfoEntity> bs = new BaseService <PostFailedInfoEntity>(ctx);
         return(bs.GetAll().Include(e => e.PostHistory).Include(e => e.User).AsNoTracking().ToList().Select(e => ToDTO(e)).ToArray());
     }
 }
Пример #9
0
 public void DeletePostFailedInfo(long t_postFailedInfoId)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <PostFailedInfoEntity> bs = new BaseService <PostFailedInfoEntity>(ctx);
         bs.MarkDeleted(t_postFailedInfoId);
     }
 }
Пример #10
0
 public void DeleteShoppingCart(long t_shoppingCartItemId)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <ShoppingCartEntity> bs = new BaseService <ShoppingCartEntity>(ctx);
         bs.MarkDeleted(t_shoppingCartItemId);
     }
 }
Пример #11
0
 /// <summary>
 /// 指定id软删除
 /// </summary>
 /// <param name="t_roleId"></param>
 public void DeleteRoleInfo(long t_roleId)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <RoleInfoEntity> bs = new BaseService <RoleInfoEntity>(ctx);
         bs.MarkDeleted(t_roleId);
     }
 }
Пример #12
0
 /// <summary>
 /// 指定用户id软删除
 /// </summary>
 /// <param name="t_userStateId"></param>
 /// <returns></returns>
 public void DeleteUserState(long t_userStateId)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <UserStateEntity> bs = new BaseService <UserStateEntity>(ctx);
         bs.MarkDeleted(t_userStateId);
     }
 }
Пример #13
0
 public void DeleteCardType(long t_cardTypeId)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <CardTypeEntity> bs = new BaseService <CardTypeEntity>(ctx);
         bs.MarkDeleted(t_cardTypeId);
     }
 }
Пример #14
0
 public CardStateDTO[] GetAllCardState()
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <CardStateEntity> bs = new BaseService <CardStateEntity>(ctx);
         return(bs.GetAll().Select(e => ToDTO(e)).ToArray());
     }
 }
Пример #15
0
 public ShoppingCartDTO[] GetAllShoppingCart()
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <ShoppingCartEntity> bs = new BaseService <ShoppingCartEntity>(ctx);
         return(bs.GetAll().Include(e => e.User).Include(e => e.CardType).AsNoTracking().Select(e => ToDTO(e)).ToArray());
     }
 }
Пример #16
0
 public void DeleteShopHistory(long t_shopHistoryId)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <ShopHistoryEntity> bs = new BaseService <ShopHistoryEntity>(ctx);
         bs.MarkDeleted(t_shopHistoryId);
     }
 }
Пример #17
0
 public CardTypeDTO[] GetAllCardType()
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <CardTypeEntity> bs = new BaseService <CardTypeEntity>(ctx);
         return(bs.GetAll().Include(e => e.UserInfos).AsNoTracking().ToList().Select(e => ToDTO(e)).ToArray());
     }
 }
Пример #18
0
 /// <summary>
 /// 指定id软删除
 /// </summary>
 /// <param name="t_nodeId"></param>
 public void DeleteSysFun(long t_nodeId)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <SysFunEntity> bs = new BaseService <SysFunEntity>(ctx);
         bs.MarkDeleted(t_nodeId);
     }
 }
Пример #19
0
 /// <summary>
 /// 指定用户id软删除
 /// </summary>
 /// <param name="userInfoId"></param>
 public void DeleteUserInfo(long userInfoId)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <UserInfoEntity> bs = new BaseService <UserInfoEntity>(ctx);
         bs.MarkDeleted(userInfoId);
     }
 }
Пример #20
0
 /// <summary>
 /// 获取所有用户信息
 /// </summary>
 /// <returns></returns>
 public UserInfoDTO[] GetAllUserinfo()
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <UserInfoEntity> bs = new BaseService <UserInfoEntity>(ctx);
         var users = bs.GetAll().Include(e => e.RoleInfo).Include(e => e.UserState).AsNoTracking().ToList().Select(l => ToDTO(l)).ToArray();
         return(users);
     }
 }
Пример #21
0
 public CardDTO[] GetAllCard()
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <CardEntity> bs = new BaseService <CardEntity>(ctx);
         var cards = bs.GetAll().Include(e => e.CardType).Include(e => e.CardState).AsNoTracking().ToList().Select(l => ToDTO(l)).ToArray();
         return(cards);
     }
 }
Пример #22
0
 /// <summary>
 /// 更新ApproveState
 /// </summary>
 /// <param name="t_ApproveState"></param>
 /// <returns></returns>
 public long UpdateApproveState(ApproveStateDTO t_ApproveState)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         var state = ctx.ApproveState.Where(u => u.Id == t_ApproveState.Id).SingleOrDefault();
         state.ApproveStateName = t_ApproveState.ApproveStateName;
         ctx.SaveChanges();
         return(state.Id);
     }
 }
Пример #23
0
 /// <summary>
 /// 更新用户状态
 /// </summary>
 /// <param name="t_UserState"></param>
 /// <returns></returns>
 public long UpdateUserState(UserStateDTO t_UserState)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <UserStateEntity> bs = new BaseService <UserStateEntity>(ctx);
         var userState = bs.GetAll().Where(u => u.Id == t_UserState.Id).SingleOrDefault();
         userState.UserState     = t_UserState.UserState;
         userState.UserStateName = t_UserState.UserStateName;
         ctx.SaveChanges();
         return(userState.Id);
     }
 }
Пример #24
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="t_New"></param>
 /// <returns></returns>
 public long InsertNew(NewDTO t_New)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         NewsEntity newsEntity = new NewsEntity();
         newsEntity.NewsState = t_New.NewsState;
         newsEntity.Title     = t_New.Title;
         newsEntity.Content   = t_New.Content;
         ctx.News.Add(newsEntity);
         ctx.SaveChanges();
         return(newsEntity.Id);
     }
 }
Пример #25
0
 /// <summary>
 /// 新增ApproveState
 /// </summary>
 /// <param name="t_ApproveState"></param>
 /// <returns></returns>
 public long InsertApproveState(ApproveStateDTO t_ApproveState)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         ApproveStateEntity approveStateEntity = new ApproveStateEntity()
         {
             ApproveStateName = t_ApproveState.ApproveStateName
         };
         ctx.ApproveState.Add(approveStateEntity);
         ctx.SaveChanges();
         return(approveStateEntity.Id);
     }
 }
Пример #26
0
 /// <summary>
 /// 更新new
 /// </summary>
 /// <param name="t_New"></param>
 /// <returns></returns>
 public long UpdateNew(NewDTO t_New)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <NewsEntity> bs = new BaseService <NewsEntity>(ctx);
         var NewEntitis = bs.GetAll().Where(u => u.Id == t_New.Id).SingleOrDefault();
         NewEntitis.NewsState = t_New.NewsState;
         NewEntitis.Title     = t_New.Title;
         NewEntitis.Content   = t_New.Content;
         ctx.SaveChanges();
         return(NewEntitis.Id);
     }
 }
Пример #27
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="t_UserState"></param>
 /// <returns></returns>
 public long InsertUserState(UserStateDTO t_UserState)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         //BaseService<UserStateEntity> bs = new BaseService<UserStateEntity>(ctx);
         UserStateEntity userStateEntity = new UserStateEntity()
         {
             UserStateName = t_UserState.UserStateName
         };
         ctx.UserStates.Add(userStateEntity);
         ctx.SaveChanges();
         return(userStateEntity.Id);
     }
 }
Пример #28
0
 public long InsertShopHistory(ShopHistoryDTO t_ShopHistory)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         ShopHistoryEntity shopHistoryEntity = new ShopHistoryEntity()
         {
             CardId = t_ShopHistory.CardId,
             UserId = t_ShopHistory.UserId
         };
         ctx.ShopHistories.Add(shopHistoryEntity);
         ctx.SaveChanges();
         return(shopHistoryEntity.Id);
     }
 }
Пример #29
0
 public long InsertCardState(CardStateDTO t_CardState)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         CardStateEntity cardStateEntity = new CardStateEntity()
         {
             CardState     = t_CardState.CardState,
             CardStateName = t_CardState.CardStateName
         };
         ctx.CardState.Add(cardStateEntity);
         ctx.SaveChanges();
         return(cardStateEntity.Id);
     }
 }
Пример #30
0
 public CardTypeDTO SelectCardTypeByID(long t_cardTypeId)
 {
     using (B2CDbContext ctx = new B2CDbContext())
     {
         BaseService <CardTypeEntity> bs = new BaseService <CardTypeEntity>(ctx);
         if (bs.GetById(t_cardTypeId) != null)
         {
             return(ToDTO(bs.GetById(t_cardTypeId)));
         }
         else
         {
             return(null);
         }
     }
 }