Beispiel #1
0
        public async Task <IActionResult> Delete(string PublicID)
        {
            if (String.IsNullOrEmpty(PublicID))
            {
                return(StatusCode(404));
            }

            var extract = await _sayonaraContext.Extracts
                          .AsNoTracking()
                          .SingleOrDefaultAsync(e => e.PublicID.Equals(new System.Guid(PublicID)));

            if (extract != null)
            {
                _sayonaraContext.Extracts.Remove(extract);
                await _sayonaraContext.SaveChangesAsync();

                return(Ok());
            }
            else
            {
                return(StatusCode(404));
            }
        }
        public async Task <IActionResult> Seed([FromBody] ICollection <DocumentationView> views)
        {
            _logger.LogInformation("In DocumentationViews Seed with " + views.Count + " views");
            foreach (var view in views)
            {
                var currentView = await _sayonaraContext.DocumentationViews.Where(v => v.ID == view.ID).FirstOrDefaultAsync();

                if (currentView != null)
                {
                    currentView.Name = view.Name;
                    currentView.MedicalRecordCopy = view.MedicalRecordCopy;
                    currentView.recActive         = view.recActive;
                    _sayonaraContext.DocumentationViews.Update(currentView);
                }
                else
                {
                    _sayonaraContext.DocumentationViews.Add(new DocumentationView
                    {
                        ID                = view.ID,
                        FacilityID        = view.FacilityID,
                        Name              = view.Name,
                        MedicalRecordCopy = view.MedicalRecordCopy,
                        recActive         = view.recActive
                    });
                }
            }

            var success = false;

            try
            {
                await _sayonaraContext.SaveChangesAsync();

                success = true;
            }
            catch (Exception ex)
            {
                _logger.LogError("DocumentationView Seed failed with message: " + ex.Message);
            }

            if (success)
            {
                return(Ok());
            }
            else
            {
                return(StatusCode(500));
            }
        }
Beispiel #3
0
        public async Task <IActionResult> Seed([FromBody] ICollection <Facility> facilities)
        {
            _logger.LogInformation("In Facilities Seed with " + facilities.Count + " facilities");
            foreach (var facility in facilities)
            {
                var currentFacility = await _sayonaraContext.Facilities.Where(f => f.ID == facility.ID).FirstOrDefaultAsync();

                if (currentFacility != null)
                {
                    currentFacility.Name        = facility.Name;
                    currentFacility.Alias       = facility.Alias;
                    currentFacility.ContactName = facility.ContactName;
                    currentFacility.Address1    = facility.Address1;
                    currentFacility.Address2    = facility.Address2;
                    currentFacility.City        = facility.City;
                    currentFacility.State       = facility.State;
                    currentFacility.ZipCode     = facility.ZipCode;
                    _sayonaraContext.Facilities.Update(currentFacility);
                }
                else
                {
                    _sayonaraContext.Facilities.Add(new Facility
                    {
                        ID          = facility.ID,
                        Alias       = facility.Alias,
                        Name        = facility.Name,
                        ContactName = facility.ContactName,
                        Address1    = facility.Address1,
                        Address2    = facility.Address2,
                        City        = facility.City,
                        State       = facility.State,
                        ZipCode     = facility.ZipCode
                    });
                }
            }

            await _sayonaraContext.SaveChangesAsync();

            return(Ok());
        }