Esempio n. 1
0
        private void UpdateFieldOfWater(IdeaPoolEntities context, List <FieldOfWaterDataObject> fieldOfWaters, Idea ideaData)
        {
            List <int> fieldOfWaterIds = new List <int>();

            foreach (IdeasFieldOfWater fieldOfWater in ideaData.IdeasFieldOfWaters.ToList())
            {
                if (!fieldOfWaters.Any(x => x.Id == fieldOfWater.FieldOfWaterId))
                {
                    context.IdeasFieldOfWaters.Remove(fieldOfWater);
                }
                else
                {
                    if (fieldOfWater.FieldOfWaterId == FIELDOFWATER_OTHER_ID)
                    {
                        var other = fieldOfWaters.Single(x => x.Id == FIELDOFWATER_OTHER_ID);
                        if (fieldOfWater.Description != other.Description)
                        {
                            fieldOfWater.Description          = other.Description;
                            context.Entry(fieldOfWater).State = EntityState.Modified;
                        }
                    }
                    fieldOfWaterIds.Add(fieldOfWater.FieldOfWaterId);
                }
            }
            fieldOfwaterData.InsertIdeaFieldOfWater(context, ideaData.Id, fieldOfWaters.Where(x => !fieldOfWaterIds.Contains(x.Id)).ToList());
        }
Esempio n. 2
0
 private void UpdateFiles(IdeaPoolEntities context, List <FileDataObject> files, Idea ideaData)
 {
     foreach (File file in ideaData.Files.ToList())
     {
         if (!files.Any(x => x.Id == file.Id))
         {
             context.Files.Remove(file);
         }
     }
     fileData.Insert(context, files.Where(file => file.Id == 0).ToList(), ideaData.Id);
 }