Exemplo n.º 1
0
        public async Task <Guid> CreateNew(Guid teacherId, Guid subjectId, LaboratoryCreateModel newLaboratory)
        {
            var teacher = await _readRepository.FindByIdAsync <Domain.Entities.Teacher>(teacherId);

            var subject = await _readRepository.FindByIdAsync <Domain.Entities.Subject>(subjectId);

            var lab = Domain.Entities.Laboratory.Create(newLaboratory.Name, newLaboratory.Group, teacher,
                                                        newLaboratory.Weekday, newLaboratory.StartHour, newLaboratory.EndHour, subject);
            await _writeRepository.AddNewAsync(lab);

            await _writeRepository.SaveAsync();

            return(lab.Id);
        }
Exemplo n.º 2
0
        public async Task <Guid> Update(Guid teacherId, Guid id, LaboratoryCreateModel updatedLaboratory)
        {
            var teacher = await _readRepository.FindByIdAsync <Domain.Entities.Teacher>(teacherId);

            var exist = await _readRepository.FindByIdAsync <Domain.Entities.Laboratory>(id);

            if (exist != null)
            {
                exist.Update(updatedLaboratory.Name, updatedLaboratory.Group,
                             teacher, updatedLaboratory.Weekday, updatedLaboratory.StartHour, updatedLaboratory.EndHour);
                await _writeRepository.UpdateAsync(id, exist);

                await _writeRepository.SaveAsync();
            }
            return(exist.Id);
        }