예제 #1
0
        public ActionStatus Exists(UserIPAddress inUserIPAddressDto)
        {
            ActionStatus status = new ActionStatus();

            try
            {
                UserIPAddressDalc dalc = new UserIPAddressDalc();

                bool Exists = dalc.Exists(inUserIPAddressDto);

                status.IsSuccessful = !Exists;
            }
            catch (MNException mnEx)
            {
                //TODO:  Log error

                throw mnEx;
            }
            catch (Exception ex)
            {
                //TODO:  Log error

                throw ex;
            }

            if (!status.IsSuccessful)
            {
                status.Messages.Add(
                    new ActionMessage("An IP Address that matches this range already exists."));
            }

            return(status);
        }
예제 #2
0
        public UserIPAddress GetUserByIP(UserIPAddress inUserIPAddressDto)
        {
            UserIPAddress outUserIPAddressDto = null;

            try
            {
                UserIPAddressDalc dalc = new UserIPAddressDalc();

                outUserIPAddressDto = dalc.GetUserByIP(inUserIPAddressDto);
            }
            catch (MNException mnEx)
            {
                //TODO:  Log error

                throw mnEx;
            }
            catch (Exception ex)
            {
                //TODO:  Log error

                throw ex;
            }

            return(outUserIPAddressDto);
        }
예제 #3
0
        public List <UserIPAddress> GetList(UserIPAddress inUserIPAddressDto)
        {
            List <UserIPAddress> userIPAddresses = null;

            try
            {
                UserIPAddressDalc dalc = new UserIPAddressDalc();

                userIPAddresses = dalc.GetList(inUserIPAddressDto);
            }
            catch (MNException mnEx)
            {
                //TODO:  Log error

                throw mnEx;
            }
            catch (Exception ex)
            {
                //TODO:  Log error

                throw ex;
            }

            return(userIPAddresses);
        }
예제 #4
0
        public ActionStatus Delete(UserIPAddress inUserIPAddressDto)
        {
            ActionStatus status = new ActionStatus();

            try
            {
                UserIPAddressDalc dalc = new UserIPAddressDalc();

                dalc.Delete(inUserIPAddressDto);

                status.IsSuccessful = true;

                status.Messages.Add(new ActionMessage("IP Address deleted successfully."));
            }
            catch (MNException mnEx)
            {
                //TODO:  Log error

                throw mnEx;
            }
            catch (Exception ex)
            {
                //TODO:  Log error

                throw ex;
            }

            if (!status.IsSuccessful)
            {
                status.Messages.Add(
                    new ActionMessage("Could not delete IP Address."));
            }

            return(status);
        }
예제 #5
0
        public ActionStatus Add(UserIPAddress inUserIPAddressDto)
        {
            ActionStatus status = new ActionStatus();

            try
            {
                UserIPAddressDalc dalc = new UserIPAddressDalc();

                //Start tran
                Start();

                dalc.Add(inUserIPAddressDto);

                //commit tran
                SetComplete();

                status.IsSuccessful = true;

                status.Messages.Add(new ActionMessage("IP Address successfully added."));
            }
            catch (MNException mnEx)
            {
                //TODO:  Log error
                //abort tran
                SetAbort();

                throw mnEx;
            }
            catch (Exception ex)
            {
                //TODO:  Log error
                //abort tran
                SetAbort();

                throw ex;
            }

            if (!status.IsSuccessful)
            {
                status.Messages.Add(
                    new ActionMessage("Could not add IP Address."));
            }

            return(status);
        }
예제 #6
0
        public Login AuthenticateIP(Login inLoginDto)
        {
            if (null == inLoginDto)
            {
                throw new ArgumentNullException("inLoginDto");
            }

            if (null == inLoginDto.IPAddress)
            {
                throw new ArgumentNullException("IPAddress");
            }

            Login outLoginDto = null;

            try
            {
                string[] octets = inLoginDto.IPAddress.Split(new char[] { '.' });

                UserIPAddress inUserIPAddressDto = new UserIPAddress();

                inUserIPAddressDto.BeginAddress.Octet1 = Convert.ToInt32(octets[0]);

                inUserIPAddressDto.BeginAddress.Octet2 = Convert.ToInt32(octets[1]);

                inUserIPAddressDto.BeginAddress.Octet3 = Convert.ToInt32(octets[2]);

                inUserIPAddressDto.BeginAddress.Octet4 = Convert.ToInt32(octets[3]);

                UserIPAddressDalc dalc = new UserIPAddressDalc();

                UserIPAddress outUserIPAddressDto = dalc.GetUserByIP(inUserIPAddressDto);

                if (outUserIPAddressDto != null)
                {
                    UserFacade userFacade = new UserFacade();

                    User inUserDto = new User();

                    inUserDto.UserId = outUserIPAddressDto.UserId;

                    User outUserDto = userFacade.GetUser(inUserDto);

                    if (outUserDto != null)
                    {
                        outLoginDto = new Login();

                        outLoginDto.EmailAddress = outUserDto.EmailAddress;
                    }
                }
            }
            catch (MNException mnEx)
            {
                //TODO:  Log error

                throw mnEx;
            }
            catch (Exception ex)
            {
                //TODO:  Log error

                throw ex;
            }

            return(outLoginDto);
        }