public JsonNetResult Edit(PersonSourceViewModel vm)
 {
     if (ModelState.IsValid)
     {
         PersonSource ps = this.sourceAttachmentTasks.GetPersonSource(vm.Id.Value);
         if (ps != null)
         {
             if (vm.ReliabilityId.HasValue)
             {
                 ps.Reliability = this.sourceTasks.GetReliability(vm.ReliabilityId.Value);
             }
             ps.Commentary = vm.Commentary;
             ps.Notes      = vm.Notes;
             ps            = this.sourceAttachmentTasks.SavePersonSource(ps);
             return(JsonNet(string.Empty));
         }
         else
         {
             Response.StatusCode = (int)HttpStatusCode.NotFound;
             return(JsonNet("Person source not found."));
         }
     }
     else
     {
         return(JsonNet(this.GetErrorsForJson()));
     }
 }
示例#2
0
        public ActionResult Person(int sourceId, int targetId)
        {
            Source source = this.sourceTasks.GetSource(sourceId);

            if (source != null)
            {
                Profiling2.Domain.Prf.Persons.Person person = this.personTasks.GetPerson(targetId);
                if (person != null)
                {
                    PersonSourceViewModel vm = new PersonSourceViewModel();
                    vm.SourceId = source.Id;
                    vm.PersonId = person.Id;
                    vm.PopulateDropDowns(this.sourceTasks.GetReliabilities());

                    ViewBag.Person = person;
                    ViewBag.Source = source;

                    PersonSource ps = source.GetPersonSource(person);
                    if (ps != null)
                    {
                        // Person is already attached to Source
                        vm.Id         = ps.Id;
                        vm.Commentary = ps.Commentary;
                        vm.Notes      = ps.Notes;
                    }
                    return(View(vm));
                }
            }
            return(new HttpNotFoundResult());
        }
        public ActionResult Add(int personId)
        {
            Person p = this.personTasks.GetPerson(personId);

            if (p != null)
            {
                PersonSourceViewModel vm = new PersonSourceViewModel(p);
                vm.PopulateDropDowns(this.sourceTasks.GetReliabilities());
                return(View(vm));
            }
            return(new HttpNotFoundResult());
        }
        public ActionResult Edit(int id)
        {
            PersonSource ps = this.sourceAttachmentTasks.GetPersonSource(id);

            if (ps != null)
            {
                PersonSourceViewModel vm = new PersonSourceViewModel(ps);
                vm.PopulateDropDowns(this.sourceTasks.GetReliabilities());
                vm.PopulateSource(this.sourceTasks.GetSourceDTO(ps.Source.Id));
                return(View(vm));
            }
            return(new HttpNotFoundResult());
        }
 public JsonNetResult Add(PersonSourceViewModel vm)
 {
     if (ModelState.IsValid)
     {
         Source s = this.sourceTasks.GetSource(vm.SourceId.Value);
         Person p = this.personTasks.GetPerson(vm.PersonId.Value);
         if (s != null && p != null)
         {
             if (s.GetPersonSource(p) == null)
             {
                 PersonSource ps = new PersonSource()
                 {
                     Source     = s,
                     Person     = p,
                     Commentary = vm.Commentary,
                     Notes      = vm.Notes
                 };
                 if (vm.ReliabilityId.HasValue)
                 {
                     ps.Reliability = this.sourceTasks.GetReliability(vm.ReliabilityId.Value);
                 }
                 this.sourceAttachmentTasks.SavePersonSource(ps);
                 return(JsonNet(string.Empty));
             }
             else
             {
                 Response.StatusCode = (int)HttpStatusCode.BadRequest;
                 return(JsonNet("Source already attached to this person."));
             }
         }
         else
         {
             Response.StatusCode = (int)HttpStatusCode.NotFound;
             return(JsonNet("Person or source not found."));
         }
     }
     else
     {
         return(JsonNet(this.GetErrorsForJson()));
     }
 }
示例#6
0
 public JsonNetResult Person(PersonSourceViewModel vm)
 {
     if (vm.Id.HasValue)
     {
         this.sourceAttachmentTasks.DeletePersonSource(vm.Id.Value);
         Response.StatusCode = (int)HttpStatusCode.OK;
         return(JsonNet("Person successfully detached from source."));
     }
     else if (ModelState.IsValid)
     {
         Source source = this.sourceTasks.GetSource(vm.SourceId.Value);
         Profiling2.Domain.Prf.Persons.Person person = this.personTasks.GetPerson(vm.PersonId.Value);
         if (source != null && person != null)
         {
             if (source.GetPersonSource(person) == null)
             {
                 PersonSource ps = new PersonSource();
                 ps.Source      = source;
                 ps.Person      = person;
                 ps.Reliability = this.sourceTasks.GetReliability(vm.ReliabilityId.Value);
                 ps.Commentary  = vm.Commentary;
                 ps.Notes       = vm.Notes;
                 this.sourceAttachmentTasks.SavePersonSource(ps);
             }
             Response.StatusCode = (int)HttpStatusCode.OK;
             return(JsonNet("Person successfully attached."));
         }
         else
         {
             Response.StatusCode = (int)HttpStatusCode.NotFound;
             return(JsonNet("Person or source not found."));
         }
     }
     else
     {
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return(JsonNet("Form data failed validation."));
     }
 }