Ejemplo n.º 1
0
        public UserDevicesEntity GetUserByPhoneNo(string phoneNumber)
        {
            UserDevicesEntity patient = new UserDevicesEntity();

            try
            {
                //UserDevicesEntity
                //  patient = _unitOfWork.DeviceRepo.Get(o => o.DeviceId.Equals(phoneNumber)).FirstOrDefault();

                //patient = (from _devices in _unitOfWork.DeviceRepo.Get(o => o.PhoneNumber.Equals(phoneNumber))
                //                            join _user in _unitOfWork.UserEntityRepo.Get() on _devices.UserId equals _user.UserId
                //           join _refreshtokens in _unitOfWork.RefreshTokenRepo.Get() on _devices.DeviceId equals _refreshtokens.DeviceId
                //           where _devices.PhoneNumber == phoneNumber
                //                            select new UserDevicesEntity
                //                            {
                //                                UserId = _user.UserId,
                //                                Password = _user.UserPassword,
                //                                RefreshToken = _refreshtokens.RefreshToken,
                //                                ExpiresUTC= _refreshtokens.ExpiresUtc
                //                            }).FirstOrDefault();

                patient = (from _devices in _unitOfWork.DeviceRepo.Get(o => o.PhoneNumber.Equals(phoneNumber))
                           join _refreshtokens in _unitOfWork.RefreshTokenRepo.Get() on _devices.DeviceId equals _refreshtokens.DeviceId
                           where _devices.PhoneNumber == phoneNumber
                           select new UserDevicesEntity
                {
                    UserId = _devices.EmailId,
                    Password = _devices.PhoneNumber,
                    RefreshToken = _refreshtokens.RefreshToken,
                    ExpiresUTC = _refreshtokens.ExpiresUtc
                }).FirstOrDefault();
            }
            catch (Exception ex)
            {
                throw;
            }

            ////===============Mapper===========================================
            //var config = new MapperConfiguration(cfg => {
            //    cfg.CreateMap<tblDevice, DevicesEntity>();
            //});

            //IMapper mapper = config.CreateMapper();
            //deviceEntity = mapper.Map<tblDevice, DevicesEntity>(patient);
            ////===============mapper end==========================================
            return(patient);
        }
Ejemplo n.º 2
0
        public IHttpActionResult CheckUser(string phoneNumber)
        {
            UserDevicesEntity result = new UserDevicesEntity();

            try
            {
                //
                result = _authRepository.GetUserByPhoneNo(phoneNumber);
            }
            catch (Exception ex)
            {
                throw new ApiDataException(2000, "Technical error occured, Please contact administrator", HttpStatusCode.InternalServerError);
            }

            finally
            {
                if (result == null)
                {
                    throw new ApiDataException(1001, "The user is not registerd", HttpStatusCode.InternalServerError);
                }
                //  return result;
            }
            return(Ok(result));
        }