コード例 #1
0
        public HoursEntryResponseVM SubmitHoursForValidation(BaseHoursEntryRequestVM request, EntryApp entryApp, bool isOnAideLegacyMode)
        {
            // this runs when an application is validating a full entry
            // all information is present
            // nothing is saved: this is for validation only
            var resolutionDataContext = new CoreContext();

            using (var transaction = resolutionDataContext.Database.BeginTransaction())
            {
                var helper = new HoursResolutionHelper(resolutionDataContext);
                try
                {
                    var entry  = helper.GetHoursObject(request, isOnAideLegacyMode);
                    var issues = helper.GetResults(entry, EntryMode, entryApp, EntryType.Full);

                    if (issues.HasErrors || (issues.HasWarnings && !request.IgnoreWarnings.GetValueOrDefault()))
                    {
                        Rollback(transaction);
                        return(new HoursEntryResponseVM
                        {
                            HoursID = request.HoursID,
                            WasProcessed = false,
                            Messages = helper.GetResponseMessages(issues)
                        });
                    }
                    return(new HoursEntryResponseVM
                    {
                        HoursID = request.HoursID
                    });
                }
                catch (Exception e)
                {
                    Exceptions.Handle(e);
                    return(new HoursEntryResponseVM
                    {
                        HoursID = request.HoursID,
                        WasProcessed = false,
                        Messages = new List <HoursEntryResponseMessage> {
                            new HoursEntryResponseMessage {
                                Severity = MessageSeverity.Error,
                                Message = "We're sorry, but an unknown error has occurred.  Please contact your system administrator for more information."
                            }
                        }
                    });
                }
                finally
                {
                    // we're just validating, don't actually submit all of these changes
                    Rollback(transaction);
                }
            }
        }
コード例 #2
0
        public HoursEntryResponseVM SubmitHoursForProviderAppPreCheck(BaseHoursEntryRequestVM request, bool isOnAideLegacyMode)
        {
            // this runs when the mobile app is setting it's precheck
            // there are no notes present: we're validating the base information only
            // we are saving if the base information is valid
            var resolutionDataContext = new CoreContext();

            using (var transaction = resolutionDataContext.Database.BeginTransaction())
            {
                var helper = new HoursResolutionHelper(resolutionDataContext);
                try
                {
                    var entry  = helper.GetHoursObject(request, isOnAideLegacyMode);
                    var issues = helper.GetResults(entry, HoursEntryMode.ProviderEntry, EntryApp.ProviderApp, EntryType.Basic, true);
                    if (issues.HasErrors || (issues.HasWarnings && !request.IgnoreWarnings.GetValueOrDefault()))
                    {
                        Rollback(transaction);
                        return(new HoursEntryResponseVM
                        {
                            HoursID = entry.ID,
                            WasProcessed = false,
                            Messages = helper.GetResponseMessages(issues)
                        });
                    }

                    resolutionDataContext.SaveChanges();
                    transaction.Commit();
                    return(new HoursEntryResponseVM
                    {
                        HoursID = entry.ID,
                        WasProcessed = true
                    });
                }
                catch (Exception e)
                {
                    Rollback(transaction);
                    Exceptions.Handle(e);
                    return(new HoursEntryResponseVM
                    {
                        HoursID = request.HoursID,
                        WasProcessed = false,
                        Messages = new List <HoursEntryResponseMessage> {
                            new HoursEntryResponseMessage {
                                Severity = MessageSeverity.Error,
                                Message = "We're sorry, but an unknown error has occurred.  Please contact your system administrator for more information. (ExecInf:" + e.ToString() + ");"
                            }
                        }
                    });
                }
            }
        }
コード例 #3
0
        public HoursEntryResponseVM SubmitHoursForProviderAppManualEntryInitialValidation(BaseHoursEntryRequestVM request, bool isOnAideLegacyMode)
        {
            // this runs when the mobile app is pre-validating a manual entry
            // there are no notes present: we're validating the base information only
            // we are not saving anything
            var resolutionDataContext = new CoreContext();

            using (var transaction = resolutionDataContext.Database.BeginTransaction())
            {
                var helper = new HoursResolutionHelper(resolutionDataContext);
                try
                {
                    var entry    = helper.GetHoursObject(request, isOnAideLegacyMode);
                    var issues   = helper.GetResults(entry, HoursEntryMode.ProviderEntry, EntryApp.ProviderApp, EntryType.Basic);
                    var response = new HoursEntryResponseVM
                    {
                        WasProcessed = false
                    };
                    if (issues.HasErrors || issues.HasWarnings)
                    {
                        response.Messages = helper.GetResponseMessages(issues);
                    }
                    return(response);
                }
                catch (Exception e)
                {
                    Exceptions.Handle(e);
                    return(new HoursEntryResponseVM
                    {
                        HoursID = request.HoursID,
                        WasProcessed = false,
                        Messages = new List <HoursEntryResponseMessage> {
                            new HoursEntryResponseMessage {
                                Severity = MessageSeverity.Error,
                                Message = "We're sorry, but an unknown error has occurred.  Please contact your system administrator for more information."
                            }
                        }
                    });
                }
                finally
                {
                    // we're just validating, rollback
                    Rollback(transaction);
                }
            }
        }
コード例 #4
0
        public HoursEntryResponseVM SubmitHoursRequest(BaseHoursEntryRequestVM request, EntryApp entryApp, bool isOnAideLegacyMode)
        {
            // this runs when an application is saving a full entry
            // all information is present
            // validation should have been done already, but we run again for good measure
            // this entry is saved to the database if valid
            if (EntryMode == HoursEntryMode.ManagementEntry)
            {
                request.IgnoreWarnings = true;
            }

            var resolutionDataContext = new CoreContext();
            var helper = new HoursResolutionHelper(resolutionDataContext);
            var entry  = helper.GetHoursObject(request, isOnAideLegacyMode);

            helper.Prepare(entry, EntryMode);

            using (var transaction = resolutionDataContext.Database.BeginTransaction())
            {
                helper.Transaction = transaction;
                try
                {
                    var issues = helper.GetResults(entryApp);
                    if (issues.HasErrors || (issues.HasWarnings && !request.IgnoreWarnings.GetValueOrDefault()))
                    {
                        Rollback(transaction);
                        return(new HoursEntryResponseVM
                        {
                            HoursID = request.HoursID,
                            WasProcessed = false,
                            Messages = helper.GetResponseMessages(issues)
                        });
                    }

                    var signatureType = "image/png";
                    if (request.HasSignatures)
                    {
                        entry.SessionSignature = new SessionSignature
                        {
                            ProviderSignature     = request.Signatures[0].Base64Signature,
                            ProviderName          = request.Signatures[0].Name,
                            ProviderSignatureType = signatureType,
                            ParentSignature       = request.Signatures[1].Base64Signature,
                            ParentName            = request.Signatures[1].Name,
                            ParentSignatureType   = signatureType
                        };
                    }


                    if (request.AllowHasDataChanges)
                    {
                        entry.HasCatalystData = request.HasData;
                    }
                    if (request.CatalystPreloadID.HasValue)
                    {
                        entry.HasCatalystData = true;
                        var preload = resolutionDataContext.CatalystPreloadEntries.Find(request.CatalystPreloadID.Value);
                        if (preload != null)
                        {
                            preload.IsResolved = true;
                        }
                    }
                    resolutionDataContext.SaveChanges();
                    transaction.Commit();
                    return(new HoursEntryResponseVM
                    {
                        HoursID = request.HoursID,
                        WasProcessed = true,
                    });
                }
                catch (Exception e)
                {
                    Rollback(transaction);
                    Exceptions.Handle(e);
                    return(new HoursEntryResponseVM
                    {
                        HoursID = request.HoursID,
                        WasProcessed = false,
                        Messages = new List <HoursEntryResponseMessage> {
                            new HoursEntryResponseMessage {
                                Severity = MessageSeverity.Error,
                                Message = "We're sorry, but an unknown error has occurred.  Please contact your system administrator for more information."
                            }
                        }
                    });
                }
            }
        }