Exemple #1
0
        protected override FieldGroup DoPostPutDto(Client currentClient, FieldGroupDTO dto, FieldGroup entity, string path, object param)
        {
            if (entity == null)
            {
                entity = new FieldGroup();
            }
            GetMapper.Map(dto, entity);
            if (dto.PeopleFields != null)
            {
                PeopleFieldRepository.DeleteRange(entity.PeopleFields.Where(d => !dto.PeopleFields.Any(x => x.Id == d.Id)));
                dto.PeopleFields.ForEach(peopleField =>
                {
                    if (entity.PeopleFields.Count != 0 && peopleField.Id != 0 &&
                        entity.PeopleFields.Find(p => p.Id == peopleField.Id) != null)
                    {
                        return;
                    }
                    PeopleField toAdd = PeopleFieldService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, peopleField, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.PeopleFields.Add(toAdd);
                    }
                });
            }
            return(entity);
        }
Exemple #2
0
        virtual public void PostFieldForFieldGroup(Client currentClient, int FieldGroupId, int PeopleId)
        {
            if (!((PeopleFieldValidation)validation).PostFieldValidation(validationDictionnary, currentClient, FieldGroupId, PeopleId))
            {
                throw new ManahostValidationException(validationDictionnary);
            }
            repo.includes.Add("FieldGroup");
            repo.includes.Add("People");
            IEnumerable <PeopleField> fields = PeopleFieldRepository.GetPeopleFieldsByFieldGroup(FieldGroupId, currentClient.Id);

            foreach (PeopleField curr in fields)
            {
                curr.FieldGroup = null;
                curr.People     = PeopleRepository.GetPeopleById(PeopleId, currentClient.Id);
                PeopleRepository.Add(curr);
            }
            PeopleRepository.Save();
        }
Exemple #3
0
 public void Init()
 {
     ctx  = EFContext.CreateContext();
     repo = new PeopleFieldRepository(ctx);
 }