Ejemplo n.º 1
0
        public async Task<IHttpActionResult> GetCalvesTotal()
        {
            var result = new ServiceProcessingResult<List<Calf>>();

            var calfService = new CalfDataService();
            var calfResult = await calfService.getActiveCalves(LoggedInUser.ClientID);
            if (!calfResult.IsSuccessful)
            {
                result.Error = new ProcessingError("An error occurred while getting total calves.","Could not retrieve total calves, please try again. If the problem persists contact support.", true);
                result.IsSuccessful = false;
                return Ok(result);
            }


            result.IsSuccessful = true;
            result.Data = calfResult.Data;

            return Ok(result);
        }
Ejemplo n.º 2
0
        public async Task<IHttpActionResult> GetActiveCalves()
        {
            var calfService = new CalfDataService();
            try
            {
                var processingResult = await calfService.getActiveCalves(LoggedInUser.ClientID);
                if (!processingResult.IsSuccessful)
                {
                    processingResult.Error = new ProcessingError("An error occurred while getting all available Calves.", "Could not retrieve Calves, please try again. If the problem persists contact support.", true);
                    return Ok(processingResult);
                }

                processingResult.Data = processingResult.Data.OrderBy(c => c.TagNumber).ToList();
                return Ok(processingResult);
            }
            catch (Exception ex)
            {
                var processingResult = new ServiceProcessingResult();

                return Ok(processingResult);
            }
        }