Ejemplo n.º 1
0
        // GET: Bills/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var bill = await _bll.Bills.FindAsync(id);

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

            var vm = new WebApp.Areas.Admin.ViewModels.BillCreateEditViewModel();

            vm.Bill             = bill;
            vm.ClientSelectList = new SelectList(
                await _bll.Clients.AllAsync(),
                nameof(BLL.App.DTO.Client.Id),
                nameof(BLL.App.DTO.Client.CompanyName));

            vm.WorkObjectSelectList = new SelectList(
                await _bll.WorkObjects.AllAsync(),
                nameof(BLL.App.DTO.WorkObject.Id),
                nameof(BLL.App.DTO.WorkObject.Id));
            return(View(vm));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, WebApp.Areas.Admin.ViewModels.BillCreateEditViewModel vm)
        {
            if (id != vm.Bill.Id)
            {
                return(NotFound());
            }


            if (ModelState.IsValid)
            {
                _bll.Bills.Update(vm.Bill);
                await _bll.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            vm.ClientSelectList = new SelectList(
                await _bll.Clients.AllAsync(),
                nameof(BLL.App.DTO.Client.Id),
                nameof(BLL.App.DTO.Client.CompanyName));

            vm.WorkObjectSelectList = new SelectList(
                await _bll.WorkObjects.AllAsync(),
                nameof(BLL.App.DTO.WorkObject.Id),
                nameof(BLL.App.DTO.WorkObject.Id));

            return(View(vm));
        }
Ejemplo n.º 3
0
        // GET: Bills/Create
        public async Task <IActionResult> Create()
        {
            var vm = new WebApp.Areas.Admin.ViewModels.BillCreateEditViewModel();

            vm.ClientSelectList = new SelectList(
                await _bll.Clients.AllAsync(),
                nameof(BLL.App.DTO.Client.Id),
                nameof(BLL.App.DTO.Client.CompanyName));

            vm.WorkObjectSelectList = new SelectList(
                await _bll.WorkObjects.AllAsync(),
                nameof(BLL.App.DTO.WorkObject.Id),
                nameof(BLL.App.DTO.WorkObject.Id));
            return(View(vm));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> CreateForClient(int clientId)
        {
            var vm = new WebApp.Areas.Admin.ViewModels.BillCreateEditViewModel();

            ViewData["client"] = await _bll.Clients.FindAsync(clientId);

//            vm.ClientSelectList = new SelectList(
//                await _bll.Clients.AllAsync(),
//                nameof(BLL.App.DTO.Client.Id),
//                nameof(BLL.App.DTO.Client.CompanyName));

//            vm.AppUserSelectList = new SelectList(
//                await _bll.AppUsers.AllAsync(),
//                nameof(BLL.App.DTO.Identity.AppUser.Id),
//                nameof(BLL.App.DTO.Identity.AppUser.FirstLastName));

            return(View(vm));
        }
Ejemplo n.º 5
0
        // GET: Bills/Delete/5
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var bill = await _bll.Bills.FindAsync(id);

            if (bill == null)
            {
                return(NotFound());
            }
            var vm = new WebApp.Areas.Admin.ViewModels.BillCreateEditViewModel();

            vm.Bill           = bill;
            vm.Bill.BillLines = await _bll.BillLines.AllForBillAsync(id);

            return(View(vm));
        }