public async Task UpdateAsync(int id, string title, string description, DateTime timeStart, DateTime timeEnd, string location, int creatorId, string type, string status) { var schedule = await _scheduleRepository.GetAsync(id); if (schedule == null) { throw new ServiceException(ErrorCodes.ScheduleNotFound, $"Schedule with this id: {id} not exists."); } schedule.SetTitle(title); schedule.SetDescription(description); schedule.SetTimeStart(timeStart); schedule.SetTimeEnd(timeEnd); schedule.SetLocation(location); schedule.SetCreator(creatorId); schedule.Type = type; schedule.Status = status; _scheduleRepository.Update(schedule); _attendeeRepository.DeleteWhere(a => a.ScheduleId == id); foreach (var attendee in schedule.Attendees) { await _attendeeRepository.AddAsync(new Attendee(id, attendee.Id)); } await _unitOfWork.SaveChangesAsync(); }