Exemplo n.º 1
0
        public ActionResult CreateModal(int personId)
        {
            Person p = this.personTasks.GetPerson(personId);

            if (p != null)
            {
                ActiveScreeningViewModel vm = new ActiveScreeningViewModel(p);
                vm.DateActivelyScreened = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
                AdminUser user = this.userTasks.GetAdminUser(User.Identity.Name);
                if (user != null)
                {
                    vm.ScreenedById   = user.Id;
                    vm.ScreenedByName = user.ToString();
                }

                IList <Request>         requests;
                IEnumerable <AdminUser> users;
                var profiler = MiniProfiler.Current;

                using (profiler.Step("Getting valid requests"))
                    requests = this.requestTasks.GetValidRequests();

                using (profiler.Step("Getting active users"))
                    users = this.userTasks.GetAllAdminUsers().Where(x => !x.Archive);

                vm.PopulateDropDowns(requests, users);
                return(View(vm));
            }
            return(new HttpNotFoundResult());
        }
Exemplo n.º 2
0
 public JsonNetResult CreateModal(ActiveScreeningViewModel vm)
 {
     if (ModelState.IsValid)
     {
         Person p = this.personTasks.GetPerson(vm.PersonId);
         if (p != null)
         {
             ActiveScreening a = new ActiveScreening();
             if (vm.RequestId.HasValue)
             {
                 a.Request = this.requestTasks.Get(vm.RequestId.Value);
             }
             a.Person = p;
             a.DateActivelyScreened = DateTime.ParseExact(vm.DateActivelyScreened, "yyyy-MM-dd", CultureInfo.CurrentCulture);
             if (vm.ScreenedById.HasValue)
             {
                 a.ScreenedBy = this.userTasks.GetAdminUser(vm.ScreenedById.Value);
             }
             a.Notes = vm.Notes;
             this.personTasks.SaveActiveScreening(a);
             return(JsonNet(string.Empty));
         }
         else
         {
             Response.StatusCode = (int)HttpStatusCode.NotFound;
             return(JsonNet("Person does not exist."));
         }
     }
     else
     {
         return(JsonNet(this.GetErrorsForJson()));
     }
 }
Exemplo n.º 3
0
        public ActionResult EditModal(int personId, int id)
        {
            Person          p = this.personTasks.GetPerson(personId);
            ActiveScreening a = this.personTasks.GetActiveScreening(id);

            if (p != null && a != null)
            {
                ActiveScreeningViewModel vm = new ActiveScreeningViewModel(a);
                vm.PopulateDropDowns(this.requestTasks.GetValidRequests(), this.userTasks.GetAllAdminUsers().Where(x => !x.Archive));
                return(View(vm));
            }
            return(new HttpNotFoundResult());
        }