示例#1
0
        public bool ChangeHirerStatus(HirerInfoEntity entity)
        {
            IDbContextTransaction tran = _context.Database.BeginTransaction();

            try
            {
                if (!Utility.CheckUserExists(_context, entity.userId))
                {
                    return(false);
                }

                var query = from d in _context.M_HIRER_INFOS
                            where d.USER_ID == entity.userId
                            select d;

                M_HIRER_INFO hirer = query.Single();
                hirer.STATUS = entity.status;

                _context.SaveChanges();

                // Commit transaction.
                tran.Commit();

                return(true);
            }
            catch
            {
                // Rollback transaction.
                tran.Rollback();
                return(false);
            }
        }
示例#2
0
        public ActionResult GetHirerInfo([FromRoute] decimal userId)
        {
            HirerInfoEntity hirerInfo = Utility.GetHirerInfo(_context, userId);

            return(Ok(new Result
            {
                Status = 200,
                Message = string.Empty,
                Data = hirerInfo
            }));
        }
示例#3
0
        public ActionResult UpdateHirerInfo(HirerInfoEntity hirer)
        {
            var query = from d in _context.M_USERS
                        where d.USER_ID == hirer.userId
                        select d;

            if (query.Any())
            {
                M_USER upd = query.Single();
                upd.NAME = hirer.name;

                string avartaPath;

                if (Utility.UploadAvatar(_context, hirer.userId, hirer.avatar, hirer.avatar.path, out avartaPath))
                {
                    upd.AVATAR = avartaPath;
                }

                upd.UPD_DATETIME = Utility.GetSysDateTime();

                _context.SaveChanges();

                HirerInfoEntity hirerInfo = Utility.GetHirerInfo(_context, hirer.userId);

                return(Ok(new Result
                {
                    Status = 200,
                    Message = string.Empty,
                    Data = hirerInfo
                }));
            }

            return(Ok(new Result
            {
                Status = 404,
                Message = string.Empty,
                Data = null
            }));
        }
示例#4
0
        /// <summary>
        /// Get hirer/ company info.
        /// </summary>
        /// <param name="hirerId">Hirer Id.</param>
        /// <returns>Hirer Info Entity</returns>
        public static HirerInfoEntity GetHirerInfo(AloaiDataContext db, decimal hirerId)
        {
            HirerInfoEntity hirerEntity = new HirerInfoEntity();

            // User info.
            var user = from d in db.M_USERS
                       where d.USER_ID == hirerId
                       select d;

            if (user.Any())
            {
                M_USER userEntity = user.Single();
                // Hirer info.
                var hirerInfo = from d in db.M_HIRER_INFOS
                                where d.USER_ID == hirerId
                                select d;

                if (hirerInfo.Any())
                {
                    M_HIRER_INFO info = hirerInfo.Single();

                    hirerEntity.userId  = info.USER_ID;
                    hirerEntity.score   = info.SCORE.Value;
                    hirerEntity.likeNum = info.LIKE_NUM;
                    hirerEntity.status  = info.STATUS;

                    ImageInfoEntity avatar = new ImageInfoEntity();
                    avatar.path        = userEntity.AVATAR;
                    hirerEntity.avatar = avatar;

                    hirerEntity.name        = userEntity.NAME;
                    hirerEntity.phoneNumber = userEntity.PHONE_NUMBER;
                    hirerEntity.token       = userEntity.TOKEN;
                }
            }

            return(hirerEntity);
        }
示例#5
0
 private static HirerInfoEntity ItemToDTO(HirerInfoEntity item)
 {
     return(item);
 }