コード例 #1
0
        public IHttpActionResult GetLogged(string userName, string passWord)
        {
            var users = db.Users.ToList();

            var cryptingFactory = new CryptingFactory();
            var cryptedpw       = users.Where(r => r.UserName == userName).First().Password;
            var uncryptedpw     = cryptingFactory.Decrypt(cryptedpw);
            var validpw         = passWord == uncryptedpw;

            //  string cryptedPassword = cryptingFactory.Encrypt(passWord);


            var validUser = users.Exists(r => r.UserName == userName && validpw);
            var user      = db.Users.Where(u => u.UserName == userName).FirstOrDefault();
            var userfav   = new UserFavoriteModel(user);

            if (validUser)
            {
                return(Ok(userfav));
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #2
0
        /// <summary>
        /// This method will Add and Update the Reastaurants that are made Favroite by User.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <int> AddUpdateUserFavorite(UserFavoriteModel model)
        {
            try
            {
                object obj          = new { UserId = model.UserId, OrgnisationId = model.OrgnisationId };
                var    userfavorite = await GetDataByIdAsync(obj);

                if (userfavorite != null)
                {
                    userfavorite.userId        = model.UserId;
                    userfavorite.orgnisationId = model.OrgnisationId;
                    userfavorite.isFavorite    = model.IsFavorite;
                    await UpdateAsync(userfavorite, new { Id = userfavorite.id });

                    return(userfavorite.id);
                }
                else
                {
                    var favorite = new UserFavorites
                    {
                        userId        = model.UserId,
                        orgnisationId = model.OrgnisationId,
                        isFavorite    = model.IsFavorite
                    };

                    return(await AddAsync(favorite));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
 public FavoriteModelDTO Map(UserFavoriteModel source)
 {
     return(new FavoriteModelDTO
     {
         ModelId = source.ModelId,
         UserId = source.UserId
     });
 }
コード例 #4
0
        public IHttpActionResult GetUser(int id)
        {
            User user = db.Users.Find(id);

            if (user == null)
            {
                return(NotFound());
            }

            var userfav = new UserFavoriteModel(user);

            return(Ok(userfav));
        }
コード例 #5
0
ファイル: UserFavoriteBLL.cs プロジェクト: sdfsun/hq-server
        public bool favorite(long goodsId, int userId, Int16 platType)
        {
            UserFavoriteModel model = dal.GetModel(userId, goodsId, platType);

            if (model == null)
            {
                model            = new UserFavoriteModel();
                model.GoodsId    = goodsId;
                model.UserId     = userId;
                model.PlatType   = platType;
                model.CreateTime = DateTime.Now;
                return(dal.Add(model) == 1);
            }
            return(true);
        }
コード例 #6
0
        public async Task <bool> SetUserFavoriteModel(UserFavoriteModel favoriteModel)
        {
            using (SqlConnection connection = new SqlConnection(Constants.ConnectionStrings.DatabaseConnectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand("SetUserFavoriteModel", connection)
                {
                    CommandType = CommandType.StoredProcedure
                };
                command.Parameters.Add(new SqlParameter("UserId", favoriteModel.UserId));
                command.Parameters.Add(new SqlParameter("ModelId", favoriteModel.ModelId));

                return(await command.ExecuteNonQueryAsync() == 1);
            }
        }
コード例 #7
0
        public async Task <bool> CheckExistFavoriteUserModel(UserFavoriteModel userFavoriteModel)
        {
            using (SqlConnection connection = new SqlConnection(Constants.ConnectionStrings.DatabaseConnectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand("CheckExistFavoriteUserModel", connection)
                {
                    CommandType = CommandType.StoredProcedure
                };
                command.Parameters.Add(new SqlParameter("UserId", userFavoriteModel.UserId));
                command.Parameters.Add(new SqlParameter("ModelId", userFavoriteModel.ModelId));

                return(Convert.ToInt32(await command.ExecuteScalarAsync()) == 1);
            }
        }
コード例 #8
0
ファイル: UserFavoriteDAL.cs プロジェクト: sdfsun/hq-server
        public HQ.Model.UserFavoriteModel GetModel(int UserId, long GoodsId, Int16 platType)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from HQ_User_Favorite  where UserId=@UserId and GoodsId=@GoodsId and PlatType=@PlatType");
            var parameters = new[] {
                new SqlParameter("@UserId", UserId),
                new SqlParameter("@GoodsId", GoodsId),
                new SqlParameter("@PlatType", platType)
            };
            UserFavoriteModel model = null;

            using (IDataReader dr = DbHelperSQL.ExecuteReader(strSql.ToString()))
            {
                model = DbHelperSQL.GetEntity <UserFavoriteModel>(dr);
            }
            return(model);
        }