Esempio n. 1
0
        public ActionResult Index(ViewModels.WorkViewModel vm, string buttonValue)
        {
            switch (buttonValue)
            {
            case "Save":
                if (ModelState.IsValid)
                {
                    var work = vm.EditWork;
                    _WorkRepo.SaveWork(work);
                    vm.EditWork = null;
                    ModelState.Clear();
                }
                break;

            case "Delete":
                _WorkRepo.DeleteWork(vm.EditWork.WorkId);
                vm.EditWork = null;
                ModelState.Clear();
                break;

            default:
                vm.EditWork = null;
                ModelState.Clear();
                break;
            }
            prepWork(vm);
            return(View(vm));
        }
Esempio n. 2
0
        private void prepWork(ViewModels.WorkViewModel vm)
        {
            var cycles = GetPayCycles();
            int cycle  = int.Parse(cycles.First().Value);

            vm.Jobs = _WorkRepo.GetJobs("- Select -").Select(x => new SelectListItem {
                Text = x.Descr, Value = x.Id.ToString()
            });
            vm.WorkTypes = _LookupRepo.GetLookups("WorkType", "- Select -").Select(x => new SelectListItem {
                Text = x.Descr, Value = x.Id.ToString()
            });
            vm.PayCycles = cycles;
            if (vm.SelectedCycle == 0)
            {
                vm.SelectedCycle = cycle;
            }
            vm.WorkEntries = _WorkRepo.GetWork(vm.Contractor.Id, vm.SelectedCycle, true);
            if (vm.EditWork == null)
            {
                vm.EditWork = new Domain.Work {
                    ContractorId = vm.Contractor.Id, WorkDay = DateRef.GetWorkDay(DateTime.Today)
                };
            }
            vm.EditDays = GetEditDays(vm.SelectedCycle);
        }
Esempio n. 3
0
        public ActionResult Index()
        {
            var vm = new ViewModels.WorkViewModel {
                Contractor = LookupRepo.GetLookupByVal("Contractor", CurrentUsername)
            };

            Session["Contractor"] = vm.Contractor;
            prepWork(vm);
            return(View(vm));
        }