Пример #1
0
        public IHttpActionResult Get(string clientId)
        {
            var result = new JsonResultModel <Client>()
            {
                Success = false
            };;

            var stopWatch = GetStopWatch();

            try
            {
                result.Result  = clientsService.Get(clientId);
                result.Success = true;
                stopWatch.Stop();
                LogManager.AddInfo("ClientsController.GET");
            }
            catch (Exception ex)
            {
                stopWatch.Stop();
                LogManager.AddError("ClientsController", "Get", string.Empty, string.Empty, stopWatch.ElapsedTicks, ex);

                result.Message = ex.Message;
            }

            return(Ok(result));
        }
Пример #2
0
        public IHttpActionResult Post([FromBody] ClientModel client)
        {
            LogManager.AddInfo(DateTime.Now + $" BEGIN : PredictionsController.Post Nombre:{client.Nombre}, Apellido:{client.Apellido}, Edad:{ client.Edad} y Fecha de Nacimiento:{ client.FechaNacimiento}");

            var result = new JsonResultModel <long>()
            {
                Success = false
            };;

            var stopWatch = GetStopWatch();

            try
            {
                result.Result  = predictionsService.CalculatePosibleDeathDate(client);
                result.Success = true;
                LogManager.AddInfo(DateTime.Now + $" SUCCESS : PredictionsController.Post Nombre:{client.Nombre}, Apellido:{client.Apellido}, Edad:{ client.Edad} y Fecha de Nacimiento:{ client.FechaNacimiento}");
                stopWatch.Stop();
            }
            catch (Exception ex)
            {
                stopWatch.Stop();
                LogManager.AddError("PredictionsController", "Post", string.Empty, string.Empty, stopWatch.ElapsedTicks, ex);
                //
                result.Message = ex.Message;
            }

            return(Ok(result));
        }
Пример #3
0
        public IHttpActionResult Delete(string clientId)
        {
            LogManager.AddInfo(DateTime.Now + $" BEGIN : ClientsController.delete clientId:{clientId}");
            var result = new JsonResultModel <string>()
            {
                Success = false
            };;

            var stopWatch = GetStopWatch();

            try
            {
                clientsService.Delete(clientId);
                result.Success = true;
                LogManager.AddInfo(DateTime.Now + $" BEGIN : ClientsController.delete clientId:{clientId}");
                stopWatch.Stop();
            }
            catch (Exception ex)
            {
                stopWatch.Stop();
                LogManager.AddError("ClientsController", "delete", string.Empty, string.Empty, stopWatch.ElapsedTicks, ex);
                //
                result.Message = ex.Message;
            }

            return(Ok(result));
        }
Пример #4
0
        public IHttpActionResult Post([FromBody] Client client)
        {
            LogManager.AddInfo(DateTime.Now + $" BEGIN : ClientsController.Post Nombre:{client.Nombre}, Apellido:{client.Apellido}");
            var result = new JsonResultModel <string>()
            {
                Success = false
            };;

            var stopWatch = GetStopWatch();

            try
            {
                clientsService.Create(client);
                result.Success = true;
                LogManager.AddInfo(DateTime.Now + $" SUCCESS : ClientsController.Post Nombre:{client.Nombre}, Apellido:{client.Apellido}");
                stopWatch.Stop();
            }
            catch (Exception ex)
            {
                stopWatch.Stop();
                LogManager.AddError("ClientsController", "Post", string.Empty, string.Empty, stopWatch.ElapsedTicks, ex);
                //
                result.Message = ex.Message;
            }

            return(Ok(result));
        }
Пример #5
0
        public IHttpActionResult Post([FromBody] Kpi kpi)
        {
            LogManager.AddInfo(DateTime.Now + $" BEGIN : KpisController.Post Fecha:{kpi.Fecha}, PromedioEdad:{kpi.PromedioEdad}, DesviacionEstandar:{kpi.DesviacionEstandar}");
            var result = new JsonResultModel <string>()
            {
                Success = false
            };;

            var stopWatch = GetStopWatch();

            try
            {
                kpisService.Create(kpi);
                result.Success = true;
                LogManager.AddInfo(DateTime.Now + $" SUCCESS : KpisController.Post Fecha:{kpi.Fecha}, PromedioEdad:{kpi.PromedioEdad}, DesviacionEstandar:{kpi.DesviacionEstandar}");
                stopWatch.Stop();
            }
            catch (Exception ex)
            {
                stopWatch.Stop();
                LogManager.AddError("KpisController", "Post", string.Empty, string.Empty, stopWatch.ElapsedTicks, ex);
                //
                result.Message = ex.Message;
            }

            return(Ok(result));
        }
Пример #6
0
        public IHttpActionResult Get(int pageIndex, int pageSize)
        {
            LogManager.AddInfo(DateTime.Now + $" BEGIN : KpisController.GET pageIndex:{pageIndex}  pageSize:{pageSize}");

            var result = new JsonResultModel <PagedResultModel <Kpi> >()
            {
                Success = false
            };;

            var stopWatch = GetStopWatch();

            try
            {
                result.Result  = kpisService.Get(pageIndex, pageSize);
                result.Success = true;
                LogManager.AddInfo(DateTime.Now + $" SUCCESS : KpisController.GET pageIndex:{pageIndex}  pageSize:{pageSize}");
                stopWatch.Stop();
            }
            catch (Exception ex)
            {
                stopWatch.Stop();
                LogManager.AddError("KpisController", "Get", string.Empty, string.Empty, stopWatch.ElapsedTicks, ex);

                result.Message = ex.Message;
            }

            return(Ok(result));
        }
Пример #7
0
        public IHttpActionResult Patch(string kpiId, [FromBody] Kpi client)
        {
            LogManager.AddInfo(DateTime.Now + $" BEGIN : KpisController.patch kpiId:{kpiId}");
            var result = new JsonResultModel <string>()
            {
                Success = false
            };;

            var stopWatch = GetStopWatch();

            try
            {
                kpisService.Update(kpiId, client);
                result.Success = true;
                LogManager.AddInfo(DateTime.Now + $" BEGIN : KpisController.patch kpiId:{kpiId}");
                stopWatch.Stop();
            }
            catch (Exception ex)
            {
                stopWatch.Stop();
                LogManager.AddError("KpisController", "patch", string.Empty, string.Empty, stopWatch.ElapsedTicks, ex);
                //
                result.Message = ex.Message;
            }

            return(Ok(result));
        }