Пример #1
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()));
     }
 }
Пример #2
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());
        }
Пример #3
0
        public JsonNetResult Delete(int id)
        {
            ActiveScreening a = this.personTasks.GetActiveScreening(id);

            if (a != null)
            {
                this.personTasks.DeleteActiveScreening(a);
                Response.StatusCode = (int)HttpStatusCode.OK;
                return(JsonNet("Active screening successfully deleted."));
            }
            else
            {
                Response.StatusCode = (int)HttpStatusCode.NotFound;
                return(JsonNet("Active screening not found."));
            }
        }
Пример #4
0
 public ActiveScreeningViewModel(ActiveScreening a)
 {
     this.Id = a.Id;
     if (a.Person != null)
     {
         this.PersonId   = a.Person.Id;
         this.PersonName = a.Person.Name;
     }
     if (a.Request != null)
     {
         this.RequestId       = a.Request.Id;
         this.RequestHeadline = a.Request.Headline;
     }
     this.DateActivelyScreened = string.Format("{0:yyyy-MM-dd}", a.DateActivelyScreened);
     if (a.ScreenedBy != null)
     {
         this.ScreenedById   = a.ScreenedBy.Id;
         this.ScreenedByName = a.ScreenedBy.ToString();
     }
     this.Notes = a.Notes;
 }
Пример #5
0
 public void DeleteActiveScreening(ActiveScreening a)
 {
     a.Person.RemoveActiveScreening(a);
     this.activeScreeningRepo.Delete(a);
 }
Пример #6
0
 public ActiveScreening SaveActiveScreening(ActiveScreening a)
 {
     a.Person.AddActiveScreening(a);
     return(this.activeScreeningRepo.SaveOrUpdate(a));
 }