Exemplo n.º 1
0
        public IActionResult Index(Owner owner)
        {
            var       sessionSortState = HttpContext.Session.GetString("SortStateOwner");
            SortState sortOrder        = new SortState();

            if (sessionSortState != null)
            {
                sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
            }

            int?page = HttpContext.Session.GetInt32("OwnerPage");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("OwnerPage", 0);
            }

            IQueryable <Owner> owners = Sort(db.Owners, sortOrder,
                                             owner.FioOwner, (int)page);

            //new Employee { Surname = surname, Post = post }
            HttpContext.Session.SetObject("Owner", owner);

            OwnersViewModel employeesView = new OwnersViewModel
            {
                OwnerViewModel = owner,
                PageViewModel  = owners,
                PageNumber     = (int)page
            };

            return(View(employeesView));
        }
Exemplo n.º 2
0
        public static IMvvmBinder GetNewOwnersView(object arg)
        {
            ////IDataContext dc = new UnitTextConnectionDataContext();
            IDataContext dc = new HVCC.Shell.Models.HVCCDataContext() as IDataContext;
            IViewModel   vm = new OwnersViewModel(dc)
            {
                Caption = "Owners"
            };
            IView v = new HVCC.Shell.Views.OwnersView(vm);

            return(new MvvmBinder(dc, v, vm));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> UpdateOwner([FromBody] OwnersViewModel owners, int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var currentOwner = await ownersService.FindAsync(id);

            if (currentOwner == null)
            {
                return(NotFound());
            }

            mapper.Map <OwnersViewModel, Owners>(owners, currentOwner);

            await ownersService.Update(currentOwner);

            await ownersService.SaveChangesAsync();

            return(Ok(currentOwner));
        }
Exemplo n.º 4
0
        public IActionResult Index(SortState sortOrder)
        {
            Owner  sessionOwner     = HttpContext.Session.GetObject <Owner>("Owner");
            string sessionSortState = HttpContext.Session.GetString("SortStateClient");
            int?   page             = HttpContext.Session.GetInt32("OwnerPage");

            if (page == null)
            {
                page = 0;
                HttpContext.Session.SetInt32("OwnerPage", 0);
            }

            if (sessionOwner != null)
            {
                _owner = sessionOwner;
            }

            if (sessionSortState != null)
            {
                if (sortOrder == SortState.No)
                {
                    sortOrder = (SortState)Enum.Parse(typeof(SortState), sessionSortState);
                }
            }

            ViewData["FioOwnerSort"] = sortOrder == SortState.FioOwnerDesc ? SortState.FioOwnerAsc : SortState.FioOwnerDesc;
            HttpContext.Session.SetString("SortStateOwner", sortOrder.ToString());

            IQueryable <Owner> owners = Sort(db.Owners, sortOrder,
                                             _owner.FioOwner, (int)page);
            OwnersViewModel employeesView = new OwnersViewModel
            {
                OwnerViewModel = _owner,
                PageViewModel  = owners,
                PageNumber     = (int)page
            };

            return(View(employeesView));
        }
Exemplo n.º 5
0
 private void MainWindow_Loadid(object sender, RoutedEventArgs e)
 {
     DataContext = new OwnersViewModel();
 }