Exemplo n.º 1
0
        public ValidationIssueCollection GetResults(List <Hours> entries, HoursEntryMode entryMode, EntryApp entryApp, EntryType entryType, bool isPrecheck = false)
        {
            var repo    = new ResolutionServiceRepository(_context);
            var service = new ResolutionService(entries, repo)
            {
                EntryMode  = entryMode,
                EntryType  = entryType,
                IsPreCheck = isPrecheck
            };

            return(service.Resolve(entryApp));
        }
Exemplo n.º 2
0
        public void Prepare(Hours entry, HoursEntryMode entryMode)
        {
            var repo    = new ResolutionServiceRepository(_context);
            var service = new ResolutionService(new List <Hours>()
            {
                entry
            }, repo)
            {
                EntryMode = entryMode
            };

            _preparedService = service;
        }
Exemplo n.º 3
0
 public ValidationIssueCollection TimeBillBatchUpdate(bool ignoreWarnings, MVCxGridViewBatchUpdateValues <TimeBillGridListItemVM, int> updateValues)
 {
     using (var transaction = _context.Database.BeginTransaction())
     {
         try
         {
             var hourEntries = new List <Domain2.Hours.Hours>();
             foreach (var updatedEntry in updateValues.Update)
             {
                 var existingEntry = _context.Hours.Find(updatedEntry.HoursID);
                 existingEntry.HasCatalystData   = updatedEntry.HasCatalystData;
                 existingEntry.Service           = _context.Services.Single(x => x.ID == updatedEntry.Service.ID);
                 existingEntry.ServiceID         = existingEntry.Service.ID;
                 existingEntry.Date              = updatedEntry.Date;
                 existingEntry.StartTime         = updatedEntry.TimeIn.TimeOfDay;
                 existingEntry.EndTime           = updatedEntry.TimeOut.TimeOfDay;
                 existingEntry.ServiceLocationID = updatedEntry.ServiceLocationID.GetValueOrDefault(GetHomeDefault());
                 existingEntry.BillableHours     = (decimal)updatedEntry.Billable;
                 existingEntry.PayableHours      = (decimal)updatedEntry.Payable;
                 hourEntries.Add(existingEntry);
             }
             var repository        = new ResolutionServiceRepository(_context);
             var resolutionService = new ResolutionService(hourEntries, repository)
             {
                 UseExplicitBillableValue = true,
                 UseExplicitPayableValue  = true,
                 EntryMode = HoursEntryMode.ManagementEntry
             };
             var issues = resolutionService.Resolve();
             if (issues.HasErrors || (issues.HasWarnings && !ignoreWarnings))
             {
                 transaction.Rollback();
                 return(issues);
             }
             else
             {
                 _context.SaveChanges();
                 transaction.Commit();
                 return(issues);
             }
         }
         catch (Exception e)
         {
             transaction.Rollback();
             Exceptions.Handle(e, Global.GetWebInfo());
             throw e;
         }
     }
 }
Exemplo n.º 4
0
        public ValidationIssueCollection AddSingleHourEntry(bool ignoreWarnings, int caseID, int providerID, DateTime date, DateTime timeIn, DateTime timeOut, int serviceID, string notes, bool isAdjustment)
        {
            using (var transaction = _context.Database.BeginTransaction())
            {
                try
                {
                    var hourEntry = new Domain2.Hours.Hours
                    {
                        CaseID    = caseID,
                        Provider  = _context.Providers.Single(m => m.ID == providerID),
                        Service   = _context.Services.Single(m => m.ID == serviceID),
                        Date      = date,
                        StartTime = timeIn.TimeOfDay,
                        EndTime   = timeOut.TimeOfDay,
                        Memo      = notes
                    };
                    hourEntry.ProviderID = hourEntry.Provider.ID;
                    hourEntry.ServiceID  = hourEntry.Service.ID;

                    var repository        = new ResolutionServiceRepository(_context);
                    var resolutionService = new ResolutionService(new List <Domain2.Hours.Hours> {
                        hourEntry
                    }, repository)
                    {
                        EntryMode = HoursEntryMode.ManagementEntry
                    };
                    var issues = resolutionService.Resolve();
                    if (issues.HasErrors || (issues.HasWarnings && !ignoreWarnings))
                    {
                        transaction.Rollback();
                        return(issues);
                    }
                    else
                    {
                        _context.SaveChanges();
                        transaction.Commit();
                        return(issues);
                    }
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    Exceptions.Handle(e, Global.GetWebInfo());
                    throw e;
                }
            }
        }