Exemplo n.º 1
0
 public ShipwayService()
 {
     shipperProvider          = new ShipperProvider();
     exhibitionProvider       = new ExhibitionProvider();
     exhibitionStatusProvider = new ExhibitionStatusProvider();
     historyTripProvider      = new HistoryTripProvider();
 }
        public ActionResult ViewDetail(string id)
        {
            List <HistoryView>   list        = new List <HistoryView>();
            IHistoryTripProvider historyTrip = new HistoryTripProvider();
            var exhibition  = _exhibitionProvider.GetExhibitionById(id);
            var listhistory = historyTrip.GetAllHistoryTripByExhibitionId(id);

            ViewBag.KindService = _kindServiceProvider.GetKindServiceById(exhibition.KindServiceId).KindServiceName;
            HistoryView historyview = new HistoryView();

            foreach (var item in listhistory)
            {
                historyview.HistoryTrip      = item;
                historyview.ExhibitionStatus = _exhibitionStatusProvider.GetExhibitionStatusById(item.ExhibitionStatusId.Value).Name;
                list.Add(historyview);
            }
            ViewBag.ListHistory = list;
            return(PartialView("_ViewDetail", exhibition));
        }
        public ActionResult SaveExhibiton(Exhibition exhibition)
        {
            if (ModelState.IsValid)
            {
                exhibition.CreatedDate   = DateTime.Now;
                exhibition.CreatedUserId = ((User)Session["CurrentUser"]).Id;
                exhibition.ExhibitionId  = GenCodeRandom();
                var exhibitionStatusId = _exhibitionStatusProvider.GetIdOfExhibitionStatus("Mới tạo");
                exhibition.ExhibitionStatusId = exhibitionStatusId;
                _exhibitionProvider.InsertExhibiton(exhibition);

                IHistoryTripProvider historyTripProvider = new HistoryTripProvider();
                var historyTrip = new HistoryTrip();
                historyTrip.ExhibitionId       = exhibition.ExhibitionId;
                historyTrip.DateTrip           = exhibition.CreatedDate;
                historyTrip.ExhibitionStatusId = exhibitionStatusId;
                historyTrip.CurrentAddress     = "";
                historyTripProvider.InsertHistoryTrip(historyTrip);
            }

            return(RedirectToAction("Index", "ExhibitionCustomer"));
        }