internal List <Enroller> IsUsernameExist(string username)
 {
     try
     {
         var myItem = new EnrollerRepository().GetEnrollers().FindAll(x => x.UserName == username);
         if (!myItem.Any())
         {
             return(new List <Enroller>());
         }
         return(myItem);
     }
     catch (Exception ex)
     {
         BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
         return(null);
     }
 }
 internal List <Enroller> IsSINExist(long clientStationId, string sin)
 {
     try
     {
         //var myItem =
         //    new EnrollerRepository().GetEnrollers()
         //        .FindAll(x => x.OrganizationId == organizationId && x.EnrollerRegId == sin);
         var myItem =
             new EnrollerRepository().GetEnrollers()
             .FindAll(x => x.ClientStationId == clientStationId && x.EnrollerRegId == sin);
         if (!myItem.Any())
         {
             return(new List <Enroller>());
         }
         return(myItem);
     }
     catch (Exception ex)
     {
         BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
         return(new List <Enroller>());
     }
 }
Example #3
0
 internal List <Enroller> IsPhoneNumberExist(long organizationId, string phoneNo)
 {
     try
     {
         //var myItem =
         //    new EnrollerRepository().GetEnrollers()
         //        .FindAll(x => x.OrganizationId == organizationId && x.MobileNumber == phoneNo);
         var myItem =
             new EnrollerRepository().GetEnrollers()
             .FindAll(x => x.MobileNumber == phoneNo);
         if (!myItem.Any())
         {
             return(new List <Enroller>());
         }
         return(myItem);
     }
     catch (Exception ex)
     {
         BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
         return(null);
     }
 }
Example #4
0
        public StationRespObj RegisterStation(StationRegObj corporateInfo)
        {
            var response = new StationRespObj
            {
                ResponseStatus = new ResponseStatus
                {
                    Message      = new ResponseMessage(),
                    IsSuccessful = false,
                }
            };

            try
            {
                List <ValidationResult> valResults;
                if (!EntityValidatorHelper.Validate(corporateInfo, out valResults))
                {
                    var errorDetail = new StringBuilder();
                    if (!valResults.IsNullOrEmpty())
                    {
                        errorDetail.AppendLine("Following error occurred:");
                        valResults.ForEachx(m => errorDetail.AppendLine(m.ErrorMessage));
                    }
                    else
                    {
                        errorDetail.AppendLine("Validation error occurred! Please check all supplied parameters and try again");
                    }
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = errorDetail.ToString();
                    return(response);
                }

                var station = GetStation(corporateInfo.StationId);
                if (station == null || string.IsNullOrEmpty(station.StationName) || station.ClientStationId < 1)
                {
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Invalid Station Key";
                    return(response);
                }

                //if (string.Compare(station.StationName.Trim(), corporateInfo.StationName.Trim(), StringComparison.CurrentCultureIgnoreCase) != 0)
                //{
                //    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Incorrect Station Name";
                //    return response;
                //}

                if (string.Compare(station.StationId.Trim(), corporateInfo.StationId.Trim(), StringComparison.CurrentCultureIgnoreCase) != 0)
                {
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Incorrect Station ID";
                    return(response);
                }

                string msg;
                var    opRegId = GenerateSIN(out msg, station.StationId, station.OrganizationId);
                if (string.IsNullOrEmpty(opRegId))
                {
                    response.ResponseStatus.Message.FriendlyMessage  = "Unable to generate Operator ID";
                    response.ResponseStatus.Message.TechnicalMessage = "Unable to generate Operator ID";
                    return(response);
                }


                if (IsDuplicate(station.OrganizationId, corporateInfo.UserName, corporateInfo.Email, opRegId, corporateInfo.MobileNumber, out msg))
                {
                    response.ResponseStatus.Message.FriendlyMessage  = msg;
                    response.ResponseStatus.Message.TechnicalMessage = msg;
                    response.ResponseStatus.IsSuccessful             = false;
                    return(response);
                }

                var helper = new Enroller
                {
                    EnrollerRegId = opRegId,
                    //OrganizationId = station.OrganizationId,
                    ClientStationId     = station.ClientStationId,
                    DeviceIP            = corporateInfo.DeviceIP,
                    DeviceId            = corporateInfo.DeviceId,
                    FirstName           = corporateInfo.FirstName,
                    Surname             = corporateInfo.Surname,
                    UserName            = corporateInfo.UserName,
                    Email               = corporateInfo.Email,
                    MobileNumber        = corporateInfo.MobileNumber,
                    Status              = 1,
                    RegisteredByUserId  = 1,
                    TimeStampRegistered = DateTime.Now
                };

                //if (station.Status == 2)
                //{
                //    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "This Station is already configured and used";
                //    return response;
                //}

                //station.DeviceId = corporateInfo.DeviceId;
                //station.DeviceIP = corporateInfo.DeviceIP;
                //station.Status = 2;

                //var processedClientEnrollerStation = _enrollerRepository.Add(helper);
                var retId = new EnrollerRepository().AddEnroller(helper, out msg);
                _uoWork.SaveChanges();

                if (retId < 1)
                {
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Process Failed! Unable to process hosting information";
                    return(response);
                }


                response.APIAccessKey    = station.APIAccessKey;
                response.ClientStationId = station.ClientStationId;
                response.DeviceId        = corporateInfo.DeviceId;
                response.Surname         = corporateInfo.Surname;
                response.FirstName       = corporateInfo.FirstName;
                response.Email           = corporateInfo.Email;
                response.MobileNumber    = corporateInfo.MobileNumber;
                //response.OrganizationId = station.OrganizationId;
                response.EnrollerRegId = opRegId;
                response.EnrollerId    = retId;
                response.StationId     = station.StationId;
                response.StationName   = station.StationName;
                response.UserName      = corporateInfo.UserName;
                response.ResponseStatus.IsSuccessful = true;
                response.ResponseStatus.ReturnedId   = retId;
                return(response);


                //public string APIAccessKey;
                //public string DeviceId;
                //public string StationId;
                //public long ClientStationId;
                //public long EnrollerId;
                //public long OrganizationId;
                //public string EnrollerRegId;
                //public string Surname;
                //public string FirstName;
                //public string UserName;
                //public string MobileNumber;
                //public string Email;
            }
            catch (Exception ex)
            {
                response.ResponseStatus.Message.FriendlyMessage  = "Processing Error Occurred! Please try again later " + ex.Message;
                response.ResponseStatus.Message.TechnicalMessage = ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(response);
            }
        }
Example #5
0
        public StationRespObj RegisterStation(OperatorStationRegObj corporateInfo)
        {
            var response = new StationRespObj
            {
                ResponseStatus = new ResponseStatus
                {
                    Message      = new ResponseMessage(),
                    IsSuccessful = false,
                }
            };

            try
            {
                List <ValidationResult> valResults;
                if (!EntityValidatorHelper.Validate(corporateInfo, out valResults))
                {
                    var errorDetail = new StringBuilder();
                    if (!valResults.IsNullOrEmpty())
                    {
                        errorDetail.AppendLine("Following error occurred:");
                        valResults.ForEachx(m => errorDetail.AppendLine(m.ErrorMessage));
                    }
                    else
                    {
                        errorDetail.AppendLine("Validation error occurred! Please check all supplied parameters and try again");
                    }

                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = errorDetail.ToString();
                    return(response);
                }

                //var station = GetStation(corporateInfo.StationId);

                var enroller = new EnrollerRepository().GetEnroller(corporateInfo.UserName);
                if (enroller == null || string.IsNullOrEmpty(enroller.EnrollerRegId) || enroller.EnrollerId < 1)
                {
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Invalid Station Operator Info";
                    return(response);
                }

                var station = GetStation(enroller.ClientStationId);
                if (station == null || station.ClientStationId < 1)
                {
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Invalid Station Info";
                    return(response);
                }

                enroller.DeviceId = corporateInfo.DeviceId;
                enroller.DeviceIP = corporateInfo.DeviceIP;
                var processedClientStationEnroller = _enrollerRepository.Update(enroller);
                _uoWork.SaveChanges();

                if (processedClientStationEnroller.EnrollerId < 1)
                {
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Process Failed! Unable to process operator authorize information";
                    return(response);
                }

                response.ResponseStatus.IsSuccessful = true;
                response.APIAccessKey    = station.APIAccessKey;
                response.ClientStationId = enroller.ClientStationId;
                response.DeviceId        = corporateInfo.DeviceId;
                response.Surname         = enroller.Surname;
                response.FirstName       = enroller.FirstName;
                response.Email           = enroller.Email;
                response.MobileNumber    = enroller.MobileNumber;
                //response.OrganizationId = enroller.OrganizationId;
                response.EnrollerRegId               = enroller.EnrollerRegId;
                response.EnrollerId                  = enroller.EnrollerId;
                response.StationId                   = station.StationId;
                response.UserName                    = corporateInfo.UserName;
                response.ResponseStatus.ReturnedId   = enroller.EnrollerId;
                response.ResponseStatus.IsSuccessful = true;
                //response.ResponseStatus.ReturnedValue = retId;
                //response.DeviceId = station.DeviceId;
                return(response);
            }
            catch (Exception ex)
            {
                response.ResponseStatus.Message.FriendlyMessage  = "Processing Error Occurred! Please try again later " + ex.Message;
                response.ResponseStatus.Message.TechnicalMessage = ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(response);
            }
        }