Beispiel #1
0
        private async Task HandleDBUpload(IFormFile file, Guid guid, ImageType type)
        {
            var uri = new Uri(BaseUri, guid.ToString());
            await _context.Images.AddAsync(new Image
            {
                FileName  = file.FileName,
                Id        = guid,
                Url       = uri.AbsoluteUri,
                TimeStamp = DateTime.Now,
                Type      = type
            });

            await _context.SaveChangesAsync();
        }
Beispiel #2
0
        private async Task <bool> CloseAppointment(string referenceId)
        {
            using (_context.Database.BeginTransaction())
            {
                var appointment = _context.Events.SelectMany(p => p.Appointments).FirstOrDefault(a => a.Id.ToString() == referenceId);
                if (appointment == null)
                {
                    return(false);
                }

                appointment.IsClosed = true;
                _context.Entry(appointment).State = EntityState.Modified;
                var result = await _context.SaveChangesAsync();

                _context.Database.CommitTransaction();
                return(result == 1);
            }
        }