예제 #1
0
        public List <FrayteAddress> GetShippeOtherAddresses(int shipperId)
        {
            List <FrayteAddress> shipperOtherAddresses = new List <FrayteAddress>();

            var addresses = dbContext.UserAddresses.Where(p => p.UserId == shipperId &&
                                                          (p.AddressTypeId == (int)FrayteAddressType.OtherAddress ||
                                                           p.AddressTypeId == (int)FrayteAddressType.MainAddress)).ToList();

            if (addresses != null)
            {
                foreach (UserAddress userAddress in addresses)
                {
                    FrayteAddress address = UtilityRepository.UserAddressMapping(userAddress);

                    var countryResult = dbContext.Countries.Where(p => p.CountryId == address.Country.CountryId).FirstOrDefault();
                    if (countryResult != null)
                    {
                        address.Country.Name = countryResult.CountryName;
                        address.Country.Code = countryResult.CountryCode;
                    }

                    shipperOtherAddresses.Add(address);
                }
            }

            return(shipperOtherAddresses);
        }
예제 #2
0
        public FrayteAddress GetShipperMainAddress(int shipperId)
        {
            FrayteAddress shipperMainAddress = new FrayteAddress();

            var address = dbContext.UserAddresses.Where(p => p.UserId == shipperId && p.AddressTypeId == (int)FrayteAddressType.MainAddress).FirstOrDefault();

            if (address != null)
            {
                shipperMainAddress = UtilityRepository.UserAddressMapping(address);
            }

            return(shipperMainAddress);
        }
예제 #3
0
        public IHttpActionResult SaveShipperOtherAddress(FrayteAddress shipperOtherAddress)
        {
            FrayteResult result = new ShipperRepository().SaveShipperOtherAddress(shipperOtherAddress);

            if (result != null && result.Status)
            {
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
예제 #4
0
        public FrayteResult SaveShipperOtherAddress(FrayteAddress shipperOtherAddress)
        {
            FrayteResult result = new FrayteResult();

            UserAddress otherAddress = new UserAddress();

            if (shipperOtherAddress.UserAddressId > 0)
            {
                otherAddress = dbContext.UserAddresses.Find(shipperOtherAddress.UserAddressId);
                if (otherAddress != null)
                {
                    otherAddress.UserId    = shipperOtherAddress.UserId;
                    otherAddress.Address   = shipperOtherAddress.Address;
                    otherAddress.Address2  = shipperOtherAddress.Address2;
                    otherAddress.Address3  = shipperOtherAddress.Address3;
                    otherAddress.City      = shipperOtherAddress.City;
                    otherAddress.Suburb    = shipperOtherAddress.Suburb;
                    otherAddress.State     = shipperOtherAddress.State;
                    otherAddress.Zip       = shipperOtherAddress.Zip;
                    otherAddress.CountryId = shipperOtherAddress.Country.CountryId;

                    dbContext.SaveChanges();
                    result.Status = true;
                }
            }
            else
            {
                otherAddress.AddressTypeId = (int)FrayteAddressType.OtherAddress;
                otherAddress.UserId        = shipperOtherAddress.UserId;
                otherAddress.Address       = shipperOtherAddress.Address;
                otherAddress.Address2      = shipperOtherAddress.Address2;
                otherAddress.Address3      = shipperOtherAddress.Address3;
                otherAddress.City          = shipperOtherAddress.City;
                otherAddress.Suburb        = shipperOtherAddress.Suburb;
                otherAddress.State         = shipperOtherAddress.State;
                otherAddress.Zip           = shipperOtherAddress.Zip;
                otherAddress.CountryId     = shipperOtherAddress.Country.CountryId;

                dbContext.UserAddresses.Add(otherAddress);
                dbContext.SaveChanges();
                result.Status = true;
            }


            return(result);
        }
예제 #5
0
        public List <FrayteShipperReceiver> GetShippers(DataTable exceldata)
        {
            List <FrayteShipperReceiver> shippers = new List <FrayteShipperReceiver>();

            FrayteShipperReceiver shipper;

            foreach (DataRow shipmentdetail in exceldata.Rows)
            {
                shipper = new FrayteShipperReceiver();

                shipper.UserId      = 0;
                shipper.RoleId      = (int)FrayteUserRole.Shipper;
                shipper.CompanyName = shipmentdetail["CompanyName"].ToString();
                shipper.ContactName = shipmentdetail["ContactName"].ToString();
                shipper.ShortName   = shipmentdetail["ShortName"].ToString();
                shipper.Email       = shipmentdetail["Email"].ToString();

                shipper.TelephoneNo = shipmentdetail["TelephoneNo"].ToString();
                shipper.MobileNo    = shipmentdetail["MobileNo"].ToString();

                shipper.FaxNumber        = shipmentdetail["FaxNumber"].ToString();
                shipper.WorkingStartTime = Convert.ToDateTime(shipmentdetail["WorkingStartTime"]);
                shipper.WorkingEndTime   = Convert.ToDateTime(shipmentdetail["WorkingEndTime"]);
                shipper.WorkingWeekDay   = new WorkingWeekDay();
                string workingDay           = shipmentdetail["WorkingWeekDay"].ToString();
                var    workingWeekDayResult = dbContext.WorkingWeekDays.Where(p => p.Description == workingDay).FirstOrDefault();
                if (workingWeekDayResult != null)
                {
                    shipper.WorkingWeekDay = workingWeekDayResult;
                }
                else
                {
                    shipper.WorkingWeekDay.Description = shipmentdetail["WorkingWeekDay"].ToString();
                }

                shipper.Timezone = new TimeZoneModal();
                string weekTimezone   = shipmentdetail["Timezone"].ToString();
                var    timeZoneResult = dbContext.Timezones.Where(p => p.Name == weekTimezone).FirstOrDefault();
                if (timeZoneResult != null)
                {
                    shipper.Timezone.TimezoneId  = timeZoneResult.TimezoneId;
                    shipper.Timezone.Name        = timeZoneResult.Name;
                    shipper.Timezone.Offset      = timeZoneResult.Offset;
                    shipper.Timezone.OffsetShort = timeZoneResult.OffsetShort;
                }
                else
                {
                    shipper.Timezone.Name = shipmentdetail["Timezone"].ToString();
                }

                shipper.VATGST    = shipmentdetail["VATGST"].ToString();
                shipper.CreatedOn = DateTime.UtcNow;

                FrayteAddress shipperAddress = new FrayteAddress();

                shipperAddress.Address  = shipmentdetail["Address"].ToString();
                shipperAddress.Address2 = shipmentdetail["Address2"].ToString();
                shipperAddress.Address3 = shipmentdetail["Address3"].ToString();
                shipperAddress.Suburb   = shipmentdetail["Suburb"].ToString();
                shipperAddress.City     = shipmentdetail["City"].ToString();
                shipperAddress.State    = shipmentdetail["State"].ToString();
                shipperAddress.Zip      = shipmentdetail["Zip"].ToString();
                shipperAddress.Country  = new FrayteCountryCode();
                string countryName = shipmentdetail["Country"].ToString();
                var    country     = dbContext.Countries.Where(p => p.CountryName == countryName).FirstOrDefault();
                if (country != null)
                {
                    shipperAddress.Country.CountryId = country.CountryId;
                    shipperAddress.Country.Code      = country.CountryCode;
                    shipperAddress.Country.Name      = country.CountryName;
                }
                else
                {
                    shipperAddress.Country.Code = shipmentdetail["Country"].ToString();
                }

                shipper.UserAddress = shipperAddress;

                shippers.Add(shipper);
            }

            return(shippers);
        }
예제 #6
0
        public FrayteShipperReceiver GetShipperDetail(int shipperId)
        {
            FrayteShipperReceiver shipperReceiver = new FrayteShipperReceiver();
            WorkingWeekDay        workingDays     = new WorkingWeekDay();
            //Step 1: Get Shipper basic information
            var shipper = dbContext.Users.Where(p => p.UserId == shipperId).FirstOrDefault();

            if (shipper != null)
            {
                //Set User's bacic information
                shipperReceiver = UtilityRepository.ShipperReceiverMapping(shipper);
                // get Working Week day

                if (shipperReceiver.WorkingWeekDay.WorkingWeekDayId > 0)
                {
                    workingDays = dbContext.WorkingWeekDays.Find(shipperReceiver.WorkingWeekDay.WorkingWeekDayId);
                }


                if (workingDays != null)
                {
                    shipperReceiver.WorkingWeekDay = workingDays;
                }
                //Step 1.1: Get time zone
                var timeZone = dbContext.Timezones.Where(p => p.TimezoneId == shipper.TimezoneId).FirstOrDefault();
                if (timeZone != null)
                {
                    shipperReceiver.Timezone             = new TimeZoneModal();
                    shipperReceiver.Timezone.TimezoneId  = timeZone.TimezoneId;
                    shipperReceiver.Timezone.Name        = timeZone.Name;
                    shipperReceiver.Timezone.Offset      = timeZone.Offset;
                    shipperReceiver.Timezone.OffsetShort = timeZone.OffsetShort;
                }

                //Step 2: Get Shipper's Address information
                var shipperAddress = dbContext.UserAddresses.Where(p => p.UserId == shipperId).ToList();
                if (shipperAddress != null)
                {
                    shipperReceiver.PickupAddresses = new List <FrayteAddress>();

                    foreach (UserAddress address in shipperAddress)
                    {
                        if (address.AddressTypeId == (int)FrayteAddressType.MainAddress)
                        {
                            //Step 2.1: Set Shipper.ShipperAddress
                            shipperReceiver.UserAddress = new FrayteAddress();
                            shipperReceiver.UserAddress = UtilityRepository.UserAddressMapping(address);

                            //Step : Get country information
                            var country = dbContext.Countries.Where(p => p.CountryId == address.CountryId).FirstOrDefault();
                            if (country != null)
                            {
                                shipperReceiver.UserAddress.Country                = new FrayteCountryCode();
                                shipperReceiver.UserAddress.Country.CountryId      = country.CountryId;
                                shipperReceiver.UserAddress.Country.Code           = country.CountryCode;
                                shipperReceiver.UserAddress.Country.Name           = country.CountryName;
                                shipperReceiver.UserAddress.Country.TimeZoneDetail = new TimeZoneModal();
                                if (country.TimeZoneId != null && country.TimeZoneId > 0)
                                {
                                    var time = dbContext.Timezones.Find(country.TimeZoneId);
                                    shipperReceiver.UserAddress.Country.TimeZoneDetail.Name        = time.Name;
                                    shipperReceiver.UserAddress.Country.TimeZoneDetail.Offset      = time.Offset;
                                    shipperReceiver.UserAddress.Country.TimeZoneDetail.OffsetShort = time.OffsetShort;
                                    shipperReceiver.UserAddress.Country.TimeZoneDetail.TimezoneId  = time.TimezoneId;
                                }
                            }
                        }
                        else
                        {
                            //Step 2.2: Set Agent's other addresses
                            FrayteAddress otherAddress = UtilityRepository.UserAddressMapping(address);

                            //Step : Get country information
                            var country = dbContext.Countries.Where(p => p.CountryId == otherAddress.Country.CountryId).FirstOrDefault();
                            if (country != null)
                            {
                                otherAddress.Country                = new FrayteCountryCode();
                                otherAddress.Country.CountryId      = country.CountryId;
                                otherAddress.Country.Code           = country.CountryCode;
                                otherAddress.Country.Name           = country.CountryName;
                                otherAddress.Country.TimeZoneDetail = new TimeZoneModal();
                                if (country.TimeZoneId != null && country.TimeZoneId > 0)
                                {
                                    var time = dbContext.Timezones.Find(country.TimeZoneId);
                                    otherAddress.Country.TimeZoneDetail.Name        = time.Name;
                                    otherAddress.Country.TimeZoneDetail.Offset      = time.Offset;
                                    otherAddress.Country.TimeZoneDetail.OffsetShort = time.OffsetShort;
                                    otherAddress.Country.TimeZoneDetail.TimezoneId  = time.TimezoneId;
                                }
                            }

                            shipperReceiver.PickupAddresses.Add(otherAddress);
                        }
                    }
                }
            }

            return(shipperReceiver);
        }
예제 #7
0
        public FrayteAgent GetAgentDetail(int?agentId)
        {
            FrayteAgent    agentDetail = new FrayteAgent();
            WorkingWeekDay workingDays = new WorkingWeekDay();
            //Step 1: Get Agent's basic information
            var agent = dbContext.Users.Where(p => p.UserId == agentId).FirstOrDefault();

            if (agent != null)
            {
                agentDetail        = UtilityRepository.AgentMapping(agent);
                agentDetail.RoleId = (int)FrayteUserRole.Agent;
                // get Working Week Time
                if (agentDetail.WorkingWeekDay.WorkingWeekDayId > 0)
                {
                    workingDays = dbContext.WorkingWeekDays.Find(agentDetail.WorkingWeekDay.WorkingWeekDayId);
                }


                if (workingDays != null)
                {
                    agentDetail.WorkingWeekDay = workingDays;
                }
                //Step 1.1: Get Agent's time zone
                var timeZone = dbContext.Timezones.Where(p => p.TimezoneId == agent.TimezoneId).FirstOrDefault();
                if (timeZone != null)
                {
                    agentDetail.Timezone             = new TimeZoneModal();
                    agentDetail.Timezone.TimezoneId  = timeZone.TimezoneId;
                    agentDetail.Timezone.Name        = timeZone.Name;
                    agentDetail.Timezone.Offset      = timeZone.Offset;
                    agentDetail.Timezone.OffsetShort = timeZone.OffsetShort;
                }

                //Step 2: Get Agent's other information
                var agentOtherDetails = dbContext.UserAdditionals.Where(p => p.UserId == agentId).FirstOrDefault();
                if (agentOtherDetails != null)
                {
                    //Get associated Frayte User's detail
                    GetAssociateUsersDetail(agent.UserId, agentDetail);
                }

                // Step 3: Get AgentShipmentType
                if (agentDetail != null && agentDetail.UserId > 0)
                {
                    var agentShipmentType = dbContext.UserShipmentTypes.Where(p => p.UserId == agent.UserId).FirstOrDefault();
                    if (agentShipmentType != null)
                    {
                        agentDetail.UserShipmentTypeId = agentShipmentType.UserShipmentTypeId;
                        agentDetail.IsAir     = agentShipmentType.IsAir;
                        agentDetail.IsSea     = agentShipmentType.IsSea;
                        agentDetail.IsExpryes = agentShipmentType.IsExpryes;
                    }
                }

                //Step 4: Get Agents's Address information
                var agentAddress = dbContext.UserAddresses.Where(p => p.UserId == agentId &&
                                                                 (p.AddressTypeId == (int)FrayteAddressType.MainAddress ||
                                                                  p.AddressTypeId == (int)FrayteAddressType.OtherAddress)).ToList();
                if (agentAddress != null)
                {
                    agentDetail.OtherAddresses = new List <FrayteAddress>();

                    foreach (UserAddress address in agentAddress)
                    {
                        if (address.AddressTypeId == (int)FrayteAddressType.MainAddress)
                        {
                            //Step 3.1: Set Agent main address
                            agentDetail.UserAddress = new FrayteAddress();
                            agentDetail.UserAddress = UtilityRepository.UserAddressMapping(address);

                            //Step : Get country information
                            var country = dbContext.Countries.Where(p => p.CountryId == address.CountryId).FirstOrDefault();
                            if (country != null)
                            {
                                agentDetail.UserAddress.Country           = new FrayteCountryCode();
                                agentDetail.UserAddress.Country.CountryId = country.CountryId;
                                agentDetail.UserAddress.Country.Code      = country.CountryCode;
                                agentDetail.UserAddress.Country.Name      = country.CountryName;
                            }
                        }
                        else
                        {
                            //Step 4.2: Set Agent's other addresses
                            FrayteAddress otherAddress = UtilityRepository.UserAddressMapping(address);

                            //Step : Get country information
                            var country = dbContext.Countries.Where(p => p.CountryId == otherAddress.Country.CountryId).FirstOrDefault();
                            if (country != null)
                            {
                                otherAddress.Country           = new FrayteCountryCode();
                                otherAddress.Country.CountryId = country.CountryId;
                                otherAddress.Country.Code      = country.CountryCode;
                                otherAddress.Country.Name      = country.CountryName;
                            }

                            agentDetail.OtherAddresses.Add(otherAddress);
                        }
                    }
                }
            }
            return(agentDetail);
        }