Ejemplo n.º 1
0
        public ResponseModel <ClientsModel> GetById(int id)
        {
            var resp = new ResponseModel <ClientsModel>();

            try
            {
                IClientsRepository appRepo = new ClientsRepository(new DataBaseContext());
                var app = appRepo.GetClientsModelById(id);

                if (app != null)
                {
                    resp.Data        = app;
                    resp.Status      = 200;
                    resp.Description = "OK";
                }
                else
                {
                    resp.Status      = 200;
                    resp.Data        = null;
                    resp.Description = "Application not found";
                }
            }
            catch (Exception ex)
            {
                resp.Status      = 500;
                resp.Description = $"Error: {ex.Message}";
                resp.Data        = null;
            }

            return(resp);
        }
Ejemplo n.º 2
0
        public static string GetClientName(int id)
        {
            IClientsRepository repo = new ClientsRepository(new DataBaseContext());

            return(repo.GetClientsModelById(id)?.Name ?? string.Empty);
        }
Ejemplo n.º 3
0
        public static ClientsModel GetClient(int id)
        {
            IClientsRepository repo = new ClientsRepository(new DataBaseContext());

            return(repo.GetClientsModelById(id));
        }