Пример #1
0
        public async Task <ActionResult> Index()
        {
            CarrierRatingRepository rep = new CarrierRatingRepository();
            var allcarriers             = await rep.GetAll();

            CarrierRepository cRep = new CarrierRepository();

            var rated = allcarriers.GroupBy(x => new { x.Carrier.Name })
                        .Select(u => new
            {
                Carrier = u.Key.Name,
                Stars   = u.Sum(z => z.Stars) / u.Count()
            });

            var ratedList = new List <CarrierRating>();

            foreach (var item in rated)
            {
                ratedList.Add(new CarrierRating {
                    Stars = item.Stars, Carrier = new Carrier()
                    {
                        Name = item.Carrier
                    }
                });
            }

            return(View(ratedList));
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contactBlackCarrier">是否包含黑名单 </param>
        /// <returns></returns>
        public static List <CarrierEntity> GetCarrierAll(bool contactBlackCarrier = true)
        {
            List <CarrierEntity> all    = new List <CarrierEntity>();
            CarrierRepository    mr     = new CarrierRepository();
            List <CarrierInfo>   miList = Cache.Get <List <CarrierInfo> >("CarrierALL");
            //供应商黑名单
            List <BlackListEntity> blackList = BlackListService.GetBlackListAll();

            if (miList.IsEmpty())
            {
                miList = mr.GetAllCarrier();
                Cache.Add("CarrierALL", miList);
            }
            if (!miList.IsEmpty())
            {
                foreach (CarrierInfo mInfo in miList)
                {
                    if (!contactBlackCarrier && blackList != null && blackList.Count > 0 && blackList.Find(p => p.BlackType.Equals("Carrier") && p.UnionID == mInfo.CarrierID) != null)
                    {
                    }
                    else
                    {
                        CarrierEntity CarrierEntity = TranslateCarrierEntity(mInfo, true);
                        all.Add(CarrierEntity);
                    }
                }
            }

            return(all);
        }
Пример #3
0
        public List <FrayteCarrierModel> GetCarrierList(string carrierType)
        {
            List <FrayteCarrierModel> lstCarrier = new List <FrayteCarrierModel>();

            lstCarrier = new CarrierRepository().GetCarrierList(carrierType);

            return(lstCarrier);
        }
Пример #4
0
        public void TestInitialize()
        {
            _context = new DbTestContext(Settings.Default.MainConnectionString);
            _fixture = new Fixture();

            _repository = new CarrierRepository(new PasswordConverter(),
                                                new SqlProcedureExecutor(Settings.Default.MainConnectionString));
        }
Пример #5
0
        // GET api/carriers
        public IHttpActionResult Get()
        {
            var repository = new CarrierRepository();
            var carriers   = repository.List();
            var models     = carriers.ToModel();

            return(Ok(models));
        }
Пример #6
0
        public FrayteResult DeleteCarrier(int carrierId)
        {
            FrayteResult result = new FrayteResult();

            result = new CarrierRepository().DeleteCarrier(carrierId);

            return(result);
        }
Пример #7
0
        public List <FrayteCarrier> GetCarrierList()
        {
            List <FrayteCarrier> lstCarrier = new List <FrayteCarrier>();

            lstCarrier = new CarrierRepository().GetCarrierList();

            return(lstCarrier);
        }
Пример #8
0
        public static CarrierEntity GetCarrierById(long gid)
        {
            CarrierEntity     result = new CarrierEntity();
            CarrierRepository mr     = new CarrierRepository();
            CarrierInfo       info   = mr.GetCarrierByKey(gid);

            result = TranslateCarrierEntity(info);
            return(result);
        }
Пример #9
0
        public async Task <ActionResult> Index()
        {
            CarrierRepository rep = new CarrierRepository();
            var allcarriers       = await rep.GetAll();

            ViewBag.UserLogged = Session["LogedUserFullname"];

            return(View(allcarriers));
        }
Пример #10
0
        public static int Remove(long gid)
        {
            CarrierRepository mr = new CarrierRepository();
            int i = mr.Remove(gid);

            //List<CarrierInfo> miList = mr.GetAllCarrier();//刷新缓存
            //Cache.Add("CarrierALL", miList);
            return(i);
        }
Пример #11
0
        /// <summary>
        /// convert packlingList to list model
        /// </summary>
        /// <param name="packingList"></param>
        /// <returns></returns>
        public PackingListViewModel ConvertToListView(PackingList packingList)
        {
            PackingListViewModel model = new PackingListViewModel();

            var _customerDynamicsRepository        = new CustomerDynamicsRepository();
            var _customerAddressDynamicsRepository = new CustomerAddressDynamicsRepository();
            var _stateRepository   = new StateRepository();
            var _carrierRepository = new CarrierRepository();

            var dynamicsCustomer        = _customerDynamicsRepository.GetCustomer(packingList.CustomerId);
            var dynamicsCustomerAddress = _customerAddressDynamicsRepository.GetCustomerAddress(packingList.CustomerAddressId);
            var state     = _stateRepository.GetState((dynamicsCustomerAddress != null && !string.IsNullOrEmpty(dynamicsCustomerAddress.STATE)) ? dynamicsCustomerAddress.STATE : string.Empty);
            var stateName = (state != null && !string.IsNullOrEmpty(state.Name)) ? ", " + state.Name : string.Empty;
            var carrier   = _carrierRepository.GetCarrier(packingList.CarrierId);

            model.PackingListId   = packingList.PackingListId;
            model.CreatedDate     = (packingList.CreatedDate != null) ? packingList.CreatedDate : DateTime.MinValue;
            model.CreatedDateStr  = (packingList.CreatedDate != null) ? packingList.CreatedDate.Value.ToShortDateString() : "N/A";
            model.CustomerName    = (dynamicsCustomer != null && !string.IsNullOrEmpty(dynamicsCustomer.SHRTNAME)) ? dynamicsCustomer.SHRTNAME : "N/A";
            model.CustomerAddress = (dynamicsCustomerAddress != null) ? dynamicsCustomerAddress.ADDRESS1 + " " +
                                    dynamicsCustomerAddress.CITY + ", " + stateName : "N/A";
            model.ShipDate       = packingList.ShipDate;
            model.ShipDateStr    = packingList.ShipDate.ToShortDateString();
            model.CarrierName    = (carrier != null && !string.IsNullOrEmpty(carrier.Name)) ? carrier.Name : "N/A";
            model.TrackingNumber = (!string.IsNullOrEmpty(packingList.TrackingNumber)) ? packingList.TrackingNumber : "N/A";
            model.Notes          = (!string.IsNullOrEmpty(packingList.TrackingNumber)) ? packingList.Notes : "N/A";
            model.IsClosed       = packingList.IsClosed;
            model.ClosedDate     = (packingList.ClosedDate != null) ? packingList.ClosedDate : DateTime.MinValue;
            model.ClosedDateStr  = (packingList.ClosedDate != null) ? packingList.ClosedDate.Value.ToShortDateString() : "N/A";

            if (_customerDynamicsRepository != null)
            {
                _customerDynamicsRepository.Dispose();
                _customerDynamicsRepository = null;
            }

            if (_customerAddressDynamicsRepository != null)
            {
                _customerAddressDynamicsRepository.Dispose();
                _customerAddressDynamicsRepository = null;
            }

            if (_stateRepository != null)
            {
                _stateRepository.Dispose();
                _stateRepository = null;
            }

            if (_carrierRepository != null)
            {
                _carrierRepository.Dispose();
                _carrierRepository = null;
            }

            return(model);
        }
Пример #12
0
        public void SetUp()
        {
            var repository      = new CarrierRepository(Context);
            var repositoryEmpty = new CarrierRepository(ContextEmpty);

            var service      = new CarrierService(repository, Mapper);
            var serviceEmpty = new CarrierService(repositoryEmpty, Mapper);

            _carriersController      = new CarriersController(service);
            _carriersControllerEmpty = new CarriersController(serviceEmpty);
        }
Пример #13
0
        public async Task <ActionResult> RateCarrier()
        {
            CarrierRepository rep = new CarrierRepository();
            var allcarriers       = await rep.GetAll();

            List <SelectListItem> list = allcarriers.Select(x => new SelectListItem {
                Value = x.Name, Text = x.Name
            }).ToList();

            ViewBag.carrierNames = list;
            return(View());
        }
Пример #14
0
        public static List <CarrierEntity> GetCarrierInfoPager(PagerInfo pager)
        {
            List <CarrierEntity> all    = new List <CarrierEntity>();
            CarrierRepository    mr     = new CarrierRepository();
            List <CarrierInfo>   miList = mr.GetAllCarrierInfoPager(pager);

            foreach (CarrierInfo mInfo in miList)
            {
                CarrierEntity carEntity = TranslateCarrierEntity(mInfo);
                all.Add(carEntity);
            }
            return(all);
        }
Пример #15
0
        public static CarrierEntity GetCarrierEntityById(long cid)
        {
            CarrierEntity     result = new CarrierEntity();
            CarrierRepository mr     = new CarrierRepository();
            CarrierInfo       info   = mr.GetCarrierByKey(cid);

            if (info != null)
            {
                result = TranslateCarrierEntity(info);
                //获取联系人信息
                result.listContact = ContactService.GetContactByRule(UnionType.Carrier.ToString(), info.CarrierID);
            }
            return(result);
        }
Пример #16
0
        public static List <CarrierEntity> GetCarrierInfoByRule(string name, string mcode, int status, PagerInfo pager)
        {
            List <CarrierEntity> all    = new List <CarrierEntity>();
            CarrierRepository    mr     = new CarrierRepository();
            List <CarrierInfo>   miList = mr.GetCarrierInfoByRule(name, mcode, status, pager);

            if (!miList.IsEmpty())
            {
                foreach (CarrierInfo mInfo in miList)
                {
                    CarrierEntity storeEntity = TranslateCarrierEntity(mInfo);
                    all.Add(storeEntity);
                }
            }

            return(all);
        }
Пример #17
0
        public static List <CarrierEntity> GetCarrierByKeys(string ids)
        {
            List <CarrierEntity> all    = new List <CarrierEntity>();
            CarrierRepository    mr     = new CarrierRepository();
            List <CarrierInfo>   miList = mr.GetCarrierByKeys(ids);

            if (!miList.IsEmpty())
            {
                foreach (CarrierInfo mInfo in miList)
                {
                    CarrierEntity entity = TranslateCarrierEntity(mInfo);
                    all.Add(entity);
                }
            }

            return(all);
        }
Пример #18
0
        public async Task <ActionResult> Create(Carrier model)
        {
            if (ModelState.IsValid)
            {
                CarrierRepository rep = new CarrierRepository();

                if (rep.GetByName(model.Name).Result == null)
                {
                    throw new Exception("This Carrier already exists.");
                }
                else
                {
                    var allcarriers = await rep.AddCarrier(model);
                }
            }

            return(RedirectToAction("Index"));
        }
Пример #19
0
 public CarrierApiController(CarrierRepository repository)
 {
     this.repository = repository;
     this.OnCreated();
 }
Пример #20
0
 // Constructor
 private CarrierUseCase()
 {
     repository = CarrierRepository.OpenRepository();
 }
Пример #21
0
        public static bool ModifyCarrier(CarrierEntity entity)
        {
            long result = 0;

            if (entity != null)
            {
                CarrierRepository mr = new CarrierRepository();

                CarrierInfo CarrierInfo = TranslateCarrierInfo(entity);

                ContactJsonEntity jsonlist = null;
                if (!string.IsNullOrEmpty(entity.ContactJson))
                {
                    try
                    {
                        jsonlist = (ContactJsonEntity)JsonHelper.FromJson(entity.ContactJson, typeof(ContactJsonEntity));
                    }
                    catch (Exception ex)
                    {
                        string str = ex.ToString();
                    }
                }

                if (entity.CarrierID > 0)
                {
                    CarrierInfo.CarrierID  = entity.CarrierID;
                    CarrierInfo.ChangeDate = DateTime.Now;
                    result = mr.ModifyCarrier(CarrierInfo);
                }
                else
                {
                    CarrierInfo.ChangeDate = DateTime.Now;
                    CarrierInfo.CreateDate = DateTime.Now;
                    result = mr.CreateNew(CarrierInfo);
                }

                #region 更新联系人信息
                if (jsonlist != null)
                {
                    List <ContactJson> list = jsonlist.listContact;
                    if (list != null && list.Count > 0)
                    {
                        foreach (ContactJson cc in list)
                        {
                            ContactRepository cr      = new ContactRepository();
                            ContactInfo       contact = new ContactInfo();
                            contact.ContactName = cc.ContactName;
                            contact.Mobile      = cc.Mobile;
                            contact.Telephone   = cc.Telephone;
                            contact.Email       = cc.Email;
                            contact.Remark      = cc.Remark;
                            contact.UnionType   = UnionType.Carrier.ToString();//承运商
                            if (cc.ContactID > 0)
                            {
                                contact.ContactID  = cc.ContactID;
                                contact.UnionID    = entity.CarrierID;
                                contact.ChangeDate = DateTime.Now;
                                cr.ModifyContact(contact);
                            }
                            else
                            {
                                contact.UnionID    = entity.CarrierID > 0 ? entity.CarrierID : result;
                                contact.CreateDate = DateTime.Now;
                                contact.ChangeDate = DateTime.Now;
                                cr.CreateNew(contact);
                            }
                        }
                    }
                }
                #endregion

                List <CarrierInfo> miList = mr.GetAllCarrier();//刷新缓存
                Cache.Add("CarrierALL", miList);
            }
            return(result > 0);
        }
Пример #22
0
        /// <summary>
        /// convert packing list to view model
        /// </summary>
        /// <param name="packingList"></param>
        /// <returns></returns>
        public PackingListViewModel ConvertToView(PackingList packingList)
        {
            PackingListViewModel model = new PackingListViewModel();

            var _customerDynamicsRepository        = new CustomerDynamicsRepository();
            var _customerAddressDynamicsRepository = new CustomerAddressDynamicsRepository();
            var _stateRepository       = new StateRepository();
            var _carrierRepository     = new CarrierRepository();
            var _packingListRepository = new PackingListRepository();

            var dynamicsCustomer        = _customerDynamicsRepository.GetCustomer(packingList.CustomerId);
            var dynamicsCustomerAddress = _customerAddressDynamicsRepository.GetCustomerAddress(packingList.CustomerAddressId);
            var state     = _stateRepository.GetState((dynamicsCustomerAddress != null && !string.IsNullOrEmpty(dynamicsCustomerAddress.STATE)) ? dynamicsCustomerAddress.STATE : string.Empty);
            var stateName = (state != null && !string.IsNullOrEmpty(state.Name)) ? ", " + state.Name : string.Empty;
            var carrier   = _carrierRepository.GetCarrier(packingList.CarrierId);

            model.PackingListId     = packingList.PackingListId;
            model.CustomerId        = packingList.CustomerId;
            model.CustomerName      = (dynamicsCustomer != null && !string.IsNullOrEmpty(dynamicsCustomer.SHRTNAME)) ? dynamicsCustomer.SHRTNAME : "N/A";
            model.CustomerAddressId = packingList.CustomerAddressId;
            model.CustomerAddress   = (dynamicsCustomerAddress != null) ? dynamicsCustomerAddress.ADDRESS1 + " " +
                                      dynamicsCustomerAddress.CITY + ", " + stateName : "N/A";
            model.ShipDate        = packingList.ShipDate;
            model.ShipDateStr     = packingList.ShipDate.ToShortDateString();
            model.Freight         = packingList.Freight;
            model.CarrierId       = packingList.CarrierId;
            model.CarrierName     = (carrier != null && !string.IsNullOrEmpty(carrier.Name)) ? carrier.Name : "N/A";
            model.TrailerNumber   = (!string.IsNullOrEmpty(packingList.TrailerNumber)) ? packingList.TrailerNumber : "N/A";
            model.TrackingNumber  = (!string.IsNullOrEmpty(packingList.TrackingNumber)) ? packingList.TrackingNumber : "N/A";
            model.Notes           = (!string.IsNullOrEmpty(packingList.Notes)) ? packingList.Notes : "N/A";
            model.NetWeight       = packingList.NetWeight;
            model.GrossWeight     = packingList.GrossWeight;
            model.DeliveryDate    = (packingList.DeliveryDate != null) ? packingList.DeliveryDate : DateTime.MinValue;;
            model.DeliveryDateStr = (packingList.DeliveryDate != null) ? packingList.DeliveryDate.Value.ToShortDateString() : "N/A";
            model.IsClosed        = packingList.IsClosed;
            model.ClosedDate      = (packingList.ClosedDate != null) ? packingList.ClosedDate : DateTime.MinValue;
            model.ClosedDateStr   = (packingList.ClosedDate != null) ? packingList.ClosedDate.Value.ToShortDateString() : "N/A";
            model.CreatedDate     = (packingList.CreatedDate != null) ? packingList.CreatedDate : DateTime.MinValue;
            model.CreatedDateStr  = (packingList.CreatedDate != null) ? packingList.CreatedDate.Value.ToShortDateString() : "N/A";

            var parts = _packingListRepository.GetPackingListPartsByPackingList(packingList.PackingListId);

            if (parts != null && parts.Count > 0)
            {
                var packingListParts = new List <PackingListPartViewModel>();

                foreach (var part in parts)
                {
                    PackingListPartViewModel packingListPart = new PackingListPartConverter().ConvertToView(part);
                    packingListParts.Add(packingListPart);
                }

                model.PackingListParts = packingListParts.OrderBy(x => x.ShipCode).ThenBy(y => y.PartNumber).ThenBy(z => z.PalletNumber).ToList();
            }

            if (_customerDynamicsRepository != null)
            {
                _customerDynamicsRepository.Dispose();
                _customerDynamicsRepository = null;
            }

            if (_customerAddressDynamicsRepository != null)
            {
                _customerAddressDynamicsRepository.Dispose();
                _customerAddressDynamicsRepository = null;
            }

            if (_stateRepository != null)
            {
                _stateRepository.Dispose();
                _stateRepository = null;
            }

            if (_carrierRepository != null)
            {
                _carrierRepository.Dispose();
                _carrierRepository = null;
            }

            if (_packingListRepository != null)
            {
                _packingListRepository.Dispose();
                _packingListRepository = null;
            }

            return(model);
        }
Пример #23
0
 public CarrierService(CarrierRepository carrierRepository)
 {
     this.carrierRepository = carrierRepository;
 }
Пример #24
0
        public async Task SetUp()
        {
            var options = new DbContextOptionsBuilder <DatabaseContext>()
                          .UseInMemoryDatabase(databaseName: "TestDb")
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            context           = new DatabaseContext(options);
            busStopRepository = new BusStopRepository(context);
            routeRepository   = new RouteRepository(context);
            carrierRepository = new CarrierRepository(context);

            var routeForTest1 = new Route
            {
                Id      = 1,
                Name    = "RouteName1",
                Carrier = new Carrier
                {
                    Id   = 1,
                    Name = "CarrierName1"
                }
            };
            var routeForTest2 = new Route
            {
                Id      = 2,
                Name    = "RouteName2",
                Carrier = new Carrier
                {
                    Id   = 1,
                    Name = "CarrierName1"
                }
            };

            await busStopRepository.AddBusStopsRangeAsync(new List <BusStop>
            {
                new BusStop //FirstRoute
                {
                    Id        = 1,
                    Latitude  = 5.0,
                    Longitude = 10.0,
                    Address   = "TestAddress1",
                    Label     = "TestLabel1",
                    Route     = routeForTest1,
                    Hour      = new TimeSpan(12, 0, 0),
                },
                new BusStop
                {
                    Id        = 2,
                    Latitude  = 15.0,
                    Longitude = 20.0,
                    Address   = "TestAddress2",
                    Label     = "TestLabel2",
                    Route     = routeForTest1,
                    Hour      = new TimeSpan(12, 30, 0),
                },
                new BusStop
                {
                    Id        = 3,
                    Latitude  = 25.0,
                    Longitude = 30.0,
                    Address   = "TestAddress3",
                    Label     = "TestLabel3",
                    Route     = routeForTest1,
                    Hour      = new TimeSpan(13, 00, 0),
                },
                new BusStop //SecondRoute
                {
                    Id        = 4,
                    Latitude  = 35.0,
                    Longitude = 40.0,
                    Address   = "TestAddress4",
                    Label     = "TestLabel4",
                    Route     = routeForTest2,
                    Hour      = new TimeSpan(16, 0, 0),
                },
                new BusStop
                {
                    Id        = 5,
                    Latitude  = 45.0,
                    Longitude = 50.0,
                    Address   = "TestAddress5",
                    Label     = "TestLabel5",
                    Route     = routeForTest2,
                    Hour      = new TimeSpan(17, 0, 0),
                },
                new BusStop
                {
                    Id        = 6,
                    Latitude  = 55.0,
                    Longitude = 60.0,
                    Address   = "TestAddress6",
                    Label     = "TestLabel6",
                    Route     = routeForTest2,
                    Hour      = new TimeSpan(18, 0, 0),
                }
            });

            await carrierRepository.AddCarrierAsync(new Carrier
            {
                Id   = 2,
                Name = "CarrierName2"
            });
        }