Example #1
0
 public async Task CalculationByEmployeesAsync(CalculationFireAndForgetByEmployeeParams calculationFireAndForgetByEmployeeParams)
 {
     var calculationManager = new OverdraftCalculationManager();
     await calculationManager.CalculationByEmployeesAsync(
         calculationFireAndForgetByEmployeeParams.EmployeeIds,
         calculationFireAndForgetByEmployeeParams.IdentityWorkID,
         calculationFireAndForgetByEmployeeParams.InstanceID,
         calculationFireAndForgetByEmployeeParams.UserID);
 }
 public async Task CalculationByEmployeesAsync(CalculationFireAndForgetByEmployeeParams calculationFireAndForgetByEmployeeParams)
 {
     //call service async
     await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, _authorizationHeader,
                                                        new Uri($"{_cotorraUri}/CalculationByEmployee"), new object[] { calculationFireAndForgetByEmployeeParams }).ContinueWith((i) =>
     {
         if (i.Exception != null)
         {
             throw i.Exception;
         }
     });
 }
Example #3
0
 public async Task CalculationByEmployeesAsync(CalculationFireAndForgetByEmployeeParams calculationFireAndForgetByEmployeeParams)
 {
     await _client.CalculationByEmployeesAsync(calculationFireAndForgetByEmployeeParams);
 }
Example #4
0
        public async Task <JsonResult> SaveIncidents(List <Incident> incidents, Guid employeeID, Guid periodDetailID, DateTime capturedOnDate)
        {
            var incidentsList = new List <Incident>();
            var incidentsDays = new List <DateTime>();

            for (int i = 0; i < incidents.Count(); i++)
            {
                var incident = new Incident()
                {
                    ID             = Guid.NewGuid(),
                    Name           = String.Empty,
                    Description    = String.Empty,
                    PeriodDetailID = incidents[i].PeriodDetailID,
                    IncidentTypeID = incidents[i].IncidentTypeID,
                    EmployeeID     = incidents[i].EmployeeID,
                    Value          = incidents[i].Value,
                    Date           = incidents[i].Date.Date,

                    //Common
                    InstanceID   = SessionModel.InstanceID,
                    CompanyID    = SessionModel.CompanyID,
                    Active       = true,
                    CreationDate = DateTime.Now,
                    StatusID     = 1,
                    user         = SessionModel.IdentityID,
                    Timestamp    = DateTime.Now
                };

                incidentsDays.Add(incidents[i].Date.Date);
                incidentsList.Add(incident);
            }

            //Order the dates
            incidentsDays = incidentsDays.OrderBy(x => x.Date).ToList();

            if (incidentsList.Count() > 0)
            {
                var minDate = incidentsDays.First().Date;
                var maxDate = incidentsDays.Last().Date;

                //Just delete incidents of days
                await incidentsClient.DeleteByExpresssionAsync(x =>
                                                               x.EmployeeID == employeeID &&
                                                               x.PeriodDetailID == periodDetailID &&
                                                               x.Date.Date >= minDate && x.Date.Date <= maxDate &&
                                                               x.InstanceID == SessionModel.InstanceID && x.Active == true,
                                                               SessionModel.CompanyID);

                //Save again
                await incidentsClient.CreateAsync(incidentsList, SessionModel.CompanyID);
            }
            else if (incidentsList.Count() == 0)
            {
                var date = capturedOnDate.Date;

                //Just delete incidents of days
                await incidentsClient.DeleteByExpresssionAsync(x =>
                                                               x.EmployeeID == employeeID &&
                                                               x.PeriodDetailID == periodDetailID &&
                                                               x.Date.Date == date &&
                                                               x.InstanceID == SessionModel.InstanceID && x.Active == true,
                                                               SessionModel.CompanyID);

                //fire and forget calculation
                var calculationFireAndForgetParams = new CalculationFireAndForgetByEmployeeParams()
                {
                    EmployeeIds = new List <Guid> {
                        employeeID
                    },
                    IdentityWorkID = SessionModel.CompanyID,
                    InstanceID     = SessionModel.InstanceID,
                    UserID         = SessionModel.IdentityID
                };
                await calculationClient.CalculationFireAndForgetByEmployeesAsync(calculationFireAndForgetParams);
            }

            return(Json("OK"));
        }