Exemplo n.º 1
0
        public ActionResult Create()
        {
            var offices = _myOfficeRepository.Search("").ToList();
            var model   = new ShippingServiceModel {
                MyOffices = offices
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public virtual ActionResult Save(ShippingServiceModel myOfficeModel)
        {
            if (myOfficeModel.ShippingServiceId <= 0) //Create News
            {
                if (!ModelState.IsValid)
                {
                    var offices = _myOfficeRepository.Search("").ToList();
                    myOfficeModel.MyOffices = offices;
                    return(View("Create", myOfficeModel));
                }
                var myOffice = new ShippingService()
                {
                    IsDeleted           = false,
                    PhoneNumber         = myOfficeModel.PhoneNumber,
                    ShippingServiceName = myOfficeModel.ShippingServiceName,
                    MyOfficeId          = myOfficeModel.MyOfficeId,
                    StartAt             = myOfficeModel.StartAt,
                    CoachStation        = myOfficeModel.CoachStation
                };
                using (UnitOfWork)
                {
                    Repository.Insert(myOffice);
                }
                //Save success
                this.SetSuccessNotification(string.Format("{0} đã được lưu thành công.", "Chành xe"));
                return(RedirectToAction("Index", new { area = "Administrator", mode = 1 }));
            }
            else //Edit user
            {
                if (!ModelState.IsValid)
                {
                    var offices = _myOfficeRepository.Search("").ToList();
                    myOfficeModel.MyOffices = offices;
                    return(View("Edit", myOfficeModel));
                }

                var myOffice = Repository.GetById(myOfficeModel.ShippingServiceId);
                myOffice.PhoneNumber         = myOfficeModel.PhoneNumber;
                myOffice.ShippingServiceName = myOfficeModel.ShippingServiceName;
                myOffice.MyOfficeId          = myOfficeModel.MyOfficeId;
                myOffice.StartAt             = myOfficeModel.StartAt;
                myOffice.CoachStation        = myOfficeModel.CoachStation;
                using (UnitOfWork)
                {
                    Repository.Update(myOffice);
                }
            }

            //Save success
            this.SetSuccessNotification(string.Format("{0} đã được lưu thành công.", "Chành xe"));
            return(RedirectToAction("Index", new { area = "Administrator" }));
        }
Exemplo n.º 3
0
        public virtual ActionResult Edit(int id)
        {
            var offices = _myOfficeRepository.Search("").ToList();
            var entity  = Repository.GetById(id);
            var model   = new ShippingServiceModel()
            {
                ShippingServiceId   = entity.ShippingServiceId,
                PhoneNumber         = entity.PhoneNumber,
                ShippingServiceName = entity.ShippingServiceName,
                Address             = entity.Address,
                MyOfficeId          = entity.MyOfficeId,
                MyOffices           = offices,
                CoachStation        = entity.CoachStation,
                StartAt             = entity.StartAt
            };

            return(View("Edit", model));
        }