Example #1
0
        public async Task <Guid> StartNewFormAsync(FormAccessLevel accessLevel, string key, PreFillLookupCriteria criteria)
        {
            var form = await _db.Forms.FirstOrDefaultAsync(f => f.AccessLevel == accessLevel && f.Key == key);

            if (form is null)
            {
                throw new Exception("No matching form");
            }

            var entry = new FormEntry
            {
                FormKey         = form.Key,
                PrefillCriteria = criteria,
                Status          = FormStatus.Open,
            };

            var preFillProcessors = await _db.PreFillProcessors.Where(p => p.FormKey == key).ToArrayAsync();

            foreach (var processor in preFillProcessors)
            {
                await _preFillProcessor.ProcessFormAsync(processor, entry);
            }

            if (form.Key == "ocif")
            {
                //var ocif = new FormOCIF
                //{
                //    Id = entry.Id,
                //    Data = entry.Data,
                //};

                //await _db.AddAsync(ocif);

                var ocif = new OCIF
                {
                    ID       = entry.Id,
                    JSONData = entry.Data
                };

                await _uiPathDb.AddAsync(ocif);

                await _uiPathDb.SaveChangesAsync();
            }

            await _db.AddAsync(entry);

            await _db.SaveChangesAsync();

            return(entry.Id);
        }
Example #2
0
        private async Task SaveArchiveRecord(FormEntry formEntry, string submissionSnapshot)
        {
            _logger.LogInformation("Archiving submission for FormEntry {formEntry}", formEntry.Id);
            await _db.AddAsync(new FormEntryArchive(formEntry, submissionSnapshot));

            await _db.SaveChangesAsync();

            _logger.LogInformation("Archived submission for FormEntry {formEntry} successfully", formEntry.Id);
        }