Exemplo n.º 1
0
        public static UserModel GetUserModel(int id, User objentity = null, string friendRequestStatus = "", bool isRequestReceived = false)
        {
            var user = new User();

            if (objentity != null)
            {
                user = objentity;
            }
            else
            {
                EFUserRepository _UserRepo = new EFUserRepository();
                user = _UserRepo.GetUserById(id);
            }
            UserModel objmodel = new UserModel();

            if (user != null)
            {
                objmodel.IsRequestReceived   = isRequestReceived;
                objmodel.FriendRequestStatus = friendRequestStatus;
                objmodel.UserID         = user.UserID;
                objmodel.FirstName      = user.FirstName;
                objmodel.LastName       = user.LastName;
                objmodel.Email          = user.Email;
                objmodel.ProfilePicture = CommonFunctions.GetProfilePicture(user.ProfilePicture, user.Gender);
                objmodel.Gender         = user.Gender;
                objmodel.DOB            = user.DOB.ToShortDateString();
                if (user.DOB != null)
                {
                    objmodel.Age = Convert.ToString(Math.Floor(DateTime.Now.Subtract(Convert.ToDateTime(user.DOB)).TotalDays / 365.0)) + " Years";
                }
                else
                {
                    objmodel.Age = "NaN";
                }
                objmodel.Bio = user.Bio;
            }
            return(objmodel);
        }
Exemplo n.º 2
0
        public static UserModel GetUserModel(long id, user objentity = null, string friendRequestStatus = "", bool isRequestReceived = false)
        {
            var user = new user();

            if (objentity != null)
            {
                user = objentity;
            }
            else
            {
                EFUserRepository _UserRepo = new EFUserRepository();
                user = _UserRepo.GetUserById(id);
            }
            UserModel objmodel = new UserModel();

            if (user != null)
            {
                objmodel.IsRequestReceived   = isRequestReceived;
                objmodel.FriendRequestStatus = friendRequestStatus;
                objmodel.UserID         = user.id;
                objmodel.Name           = user.first_name1 + " " + user.last_name1;
                objmodel.ProfilePicture = CommonFunctions.GetProfilePicture(user.user_img);
                objmodel.Gender         = "Male";
                objmodel.DOB            = user.acq_date.ToShortDateString();
                if (user.acq_date != null)
                {
                    objmodel.Age = Convert.ToString(Math.Floor(DateTime.Now.Subtract(Convert.ToDateTime(user.acq_date)).TotalDays / 365.0)) + " Years";
                }
                else
                {
                    objmodel.Age = "NaN";
                }
                objmodel.Bio = "N";
            }
            return(objmodel);
        }