Exemplo n.º 1
0
        //[Authorize]
        // data done, poco done, detail form done, need to check filters
        public HttpResponseMessage ExpirationDates(APIEnums.RollupLevel rollupLevel, APIEnums.IncludeAssistant includeAssistant, int employeeId, int schoolYearId, DateTime?startDate, DateTime?endDate)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            // Work objects //
            var response = this.Request.CreateResponse(HttpStatusCode.OK);

            LifeSpan.DTO.Dashboard.ExpirationResponse result = new ExpirationResponse();

            try
            {
                StaffReminders bll = new StaffReminders();

                result.Expirations = bll.StaffExpirations((includeAssistant == APIEnums.IncludeAssistant.True ? true : false), employeeId, schoolYearId, startDate, endDate);


                // Prepare result output //
                result.DashboardValue = result.Expirations.Count;
                result.RecordCount    = result.Expirations.Count;

                // Return summary only if requested //
                if (rollupLevel == APIEnums.RollupLevel.Summary)
                {
                    result.Expirations.Clear();
                }

                result.Success = true;
            }

            catch (Exception ex)
            {
                result.Success      = false;
                response.StatusCode = HttpStatusCode.BadRequest;
                result.Errors.Add(new Error(Error.ErrorClass.Error, string.Empty, ex.Message, ex));
            }

            stopwatch.Stop();
            result.ExecutionTimeSpan = stopwatch.Elapsed;
            result.TimeStamp         = DateTime.Now;
            response.Content         = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(result), Encoding.UTF8, "application/json");

            return(response);
        }
Exemplo n.º 2
0
        public dtoBaseResponse ModifyExpiration([FromBody] dto.dtoModifyExpiration value)
        {
            dtoBaseResponse response = new dtoBaseResponse();

            response.ErrorInfo = LastError;

            if (LastError != Adevico.APIconnection.Core.GenericError.None)
            {
                return(response);
            }

            ExpirationResponse result = coreApiService.SetExpiration(
                value.communityId,
                value.usersId,
                value.validity,
                value.extendValidity,
                value.startBehaviour);



            if (result == ExpirationResponse.NoPermission)
            {
                response.Success          = false;
                response.ErrorInfo        = Adevico.APIconnection.Core.GenericError.NoServicePermission;
                response.ServiceErrorCode = (int)RoleUpdateResponse.NoPermission;
                return(response);
            }

            response.ServiceErrorCode = (int)result;

            if (result == ExpirationResponse.AllUpdated || result == ExpirationResponse.SomeUserUpdated)
            {
                response.Success   = true;
                response.ErrorInfo = Adevico.APIconnection.Core.GenericError.None;
            }
            else
            {
                response.Success   = false;
                response.ErrorInfo = Adevico.APIconnection.Core.GenericError.InvalidDataInput;
            }

            return(response);
        }