public HttpResponseMessage Get(int id)
        {
            var banner = bannerService.Get(id);

            if (banner != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, banner));
            }
            return(Request.CreateErrorResponse(HttpStatusCode.NotFound, string.Format("Banner withe id={0} not found.", id.ToString())));
        }
        // GET: Admin/MedihubBanners/Details/5
        public ActionResult Details(Guid id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Banner banner = _bannerService.Get(id);

            if (banner == null)
            {
                return(HttpNotFound());
            }
            return(View(banner));
        }
Esempio n. 3
0
        public async Task <IActionResult> Details(int?Id)
        {
            if (Id == null)
            {
                return(NotFound());
            }
            var controller = nameof(BannersController).Split("Controller")[0];
            var html       = "detail";

            var model = await _bannerService.Get(Id);

            if (User.IsInRole(Roles.Owner) || User.Identity.IsAuthenticated)
            {
                html = "managedetail";
            }

            return(View($"~/Views/{controller}/{html}.cshtml", model));
        }
Esempio n. 4
0
        private void searchButton_Click(object sender, EventArgs e)
        {
            //si el campo de busqueda es valido
            if (ValidateChildren(ValidationConstraints.Visible))
            {
                switch (filterComboBox.SelectedItem.ToString())
                {
                //mostrar el banner con un id
                case SEARCH_BY_ID:
                    try
                    {
                        var oneElementList = new List <BannerDTO>();
                        var foundElement   = iBannerService.Get(Int32.Parse(searchTextBox.Text));

                        //si se encontro el banner
                        if (foundElement.Id != 0)
                        {
                            oneElementList.Add(foundElement);
                            bannersGridView.DataSource = oneElementList;
                            bannersGridView.Refresh();
                        }
                        else
                        {
                            bannersGridView.DataSource = null;
                            bannersGridView.Refresh();
                            MetroMessageBox.Show(this, "No hay ningun banner en el sistema que coincida con la busqueda", "No se encontraron resultados", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    catch (Exception ex)
                    {
                        MetroMessageBox.Show(this, "detalles del error: " + ex.Message, "Error al obtener banners", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    break;

                //mostrar todos los banner con el nombre ingresado
                case SEARCH_BY_NAME:
                    try
                    {
                        var campaignsResult = iBannerService.GetBannersByName(searchTextBox.Text);
                        bannersGridView.DataSource = campaignsResult;
                        bannersGridView.Refresh();
                        checkEmptyList();
                    }
                    catch (Exception ex)
                    {
                        bannersGridView.DataSource = null;
                        bannersGridView.Refresh();
                        MetroMessageBox.Show(this, "detalles del error: " + ex.Message, "Error al obtener banners", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    break;

                default:
                    break;
                }
            }
        }
        public async Task <IActionResult> Get(int id)
        {
            var banner = await _service.Get(id);

            if (banner == null)
            {
                return(NotFound());
            }

            return(Ok(banner));
        }