Esempio n. 1
0
        public void AddParticipant(Employee employee)
        {
            var participant = new ProjectParticipant
            {
                Project    = this,
                ProjectId  = Id,
                Employee   = employee,
                EmployeeId = employee.Id
            };
            var index = ParticipantsToDelete.IndexOf(s => s == participant);

            if (index == -1)
            {
                ParticipantsToAdd.Add(participant);
            }
            else
            {
                ParticipantsToDelete.RemoveAt(index);
            }
        }
Esempio n. 2
0
 public void SaveParticipants(long id = 0)
 {
     ParticipantsToAdd.ForEach(s =>
     {
         if (ParticipantsToDelete.Any(sd => sd == s))
         {
             return;
         }
         if (id != 0)
         {
             s.ProjectId = id;
         }
         DBModel.Context.Insert(s);
     });
     ParticipantsToDelete.ForEach(s =>
     {
         if (s.ProjectId != 0)
         {
             DBModel.EmployeesDB.Delete(s);
         }
     });
 }
Esempio n. 3
0
        public void UpdateParticipants()
        {
            var participants = new List <ProjectParticipant>();

            if (!Participantidfks.IsEmpty() && !ParticipantsToAdd.IsEmpty())
            {
                participants = Participantidfks.Union(ParticipantsToAdd).ToList();
            }
            else if (!Participantidfks.IsEmpty())
            {
                participants = Participantidfks.ToList();
            }
            else if (!ParticipantsToAdd.IsEmpty())
            {
                participants = ParticipantsToAdd;
            }

            Participants = new ObservableCollection <ProjectParticipant>(
                participants.Where(p => !ParticipantsToDelete.Any(pp => pp == p))
                );
            RaisePropertyChanged(nameof(Participants));
        }