Ejemplo n.º 1
0
        public ActionResult Edit(int?id)
        {
            // Kick them out if they don't offer an ID.
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }

            WorkDoneRepository workDoneRepo = new WorkDoneRepository();
            WorkDone           workDone     = workDoneRepo.GetById(id.Value);

            // Kick them out if the try a non-existant ID.
            if (workDone == null)
            {
                return(RedirectToAction("Index"));
            }

            // Populate DropDownLists
            ClientRepository   clientRepo   = new ClientRepository();
            List <Client>      clients      = clientRepo.GetClients();
            WorkTypeRepository workTypeRepo = new WorkTypeRepository();
            List <WorkType>    workTypes    = workTypeRepo.GetWorkTypes();

            // Bind the View Model
            EditWorkDone model = new EditWorkDone(clients, workTypes);

            model.Id         = id.Value;
            model.ClientId   = workDone.ClientId;
            model.WorkTypeId = workDone.WorkTypeId;
            model.StartedOn  = workDone.StartedOn;
            model.EndedOn    = workDone.EndedOn;

            return(View("Edit", model));
        }
Ejemplo n.º 2
0
        public ActionResult Finish(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }
            WorkDoneRepository repo = new WorkDoneRepository(context);
            WorkDone           wd   = repo.GetById((int)id);

            wd.Finished();
            repo.Update(wd);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            var repo          = new WorkDoneRepository(_context);
            var workDone      = repo.GetById(id);
            var clientRepo    = new ClientRepository(_context);
            var clientItems   = clientRepo.GetSelectListItems();
            var workTypeRepo  = new WorkTypeRepository(_context);
            var workTypeItems = clientRepo.GetSelectListItems();
            var formModel     = new EditWorkDone()
            {
                Id            = id,
                ClientId      = workDone.ClientId,
                WorkTypeId    = workDone.WorkTypeId,
                StartedOn     = workDone.StartedOn,
                EndedOn       = workDone.EndedOn,
                ClientItems   = clientItems,
                WorkTypeItems = workTypeItems
            };

            return(View(formModel));
        }