コード例 #1
0
ファイル: ReportService.cs プロジェクト: KostadinovK/QDetect
        public async Task <Report> AddAsync(int personId, int imageId)
        {
            if (!await context.Persons.AnyAsync(p => p.Id == personId))
            {
                throw new ArgumentException("Invalid person id");
            }

            if (!await context.Images.AnyAsync(i => i.Id == imageId))
            {
                throw new ArgumentException("Invalid image id");
            }

            var report = new Report
            {
                ImageId    = imageId,
                Image      = context.Images.First(i => i.Id == imageId),
                PersonId   = personId,
                Person     = context.Persons.First(p => p.Id == personId),
                Date       = DateTime.UtcNow,
                IsArchived = false,
            };

            await context.Reports.AddAsync(report);

            await context.SaveChangesAsync();

            return(report);
        }
コード例 #2
0
ファイル: PeopleService.cs プロジェクト: KostadinovK/QDetect
        public async Task EditAsync(int id, string name, string ucn, string city, DateTime quarantine)
        {
            if (!await ContainsUserAsync(id))
            {
                throw new ArgumentException("Invalid person id");
            }

            var person = await context.Persons.FirstAsync(p => p.Id == id);

            person.Name = name;
            person.UCN  = ucn;
            person.QuarantineEndDate = quarantine;
            person.City = city;

            context.Persons.Update(person);
            await context.SaveChangesAsync();
        }