Beispiel #1
0
        public JsonResult GET_municipality_update_filters(RequestBusinessFilter request)
        {
            try
            {
                BusinessResultResponse response = new BusinessResultResponse() { Status = a2m.Common.Responses.Response.Status.Ok };
                Municipality currentMunicipality = MunicipalityManager.getMunicipalityByNormalizedName(request.CurrentMunicipality);
                if (currentMunicipality == null){
                    a2m.A2MApplication.Log.Error("BusinessController unable to found municipality " + request.CurrentMunicipality);
                    JSONResponse responseError = new JSONResponse() { Status = a2m.Common.Responses.Response.Status.Error };
                    return Json(responseError, JsonRequestBehavior.AllowGet);
                }
                MunicipalityModel MunicipalityModel = new MunicipalityModel();
                MunicipalityModel.Municipality = currentMunicipality;
                MunicipalityModel.CurrentPage = request.CurrentPage;
                //TODO FILTERING
                BussinessManager BussinessManager = new BussinessManager();
                MunicipalityModel.BusinessList = BussinessManager.GetBusinessFromMunicipalityIdAndFilters(request.toBusinesFilter(), a2m.A2MApplication.ResultsPaginateSize);

                response.ResultHtmlView = RenderRazorViewToString("~/Views/Municipality/MunicipalitySearchResult.cshtml", MunicipalityModel);
                response.PageSize = a2m.A2MApplication.ResultsPaginateSize;
                response.TotalResult = MunicipalityModel.BusinessList.Count;
                response.NextPage = request.CurrentPage + 1;
                return Json(response, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                a2m.A2MApplication.Log.Error("BusinessController", ex);
                JSONResponse response = new JSONResponse() { Status = a2m.Common.Responses.Response.Status.Error };
                return Json(response, JsonRequestBehavior.AllowGet);

            }
        }
        /// <summary>
        /// Obtiene un negocio
        /// </summary>
        /// <param name="municipality">Municipio</param>
        /// <param name="business">Negocio</param>
        /// <returns>Vista de la ficha de un municipio</returns>
        public ActionResult Index(string municipality,string business)
        {
            try
            {
                ViewBag.Section = a2m.Common.Enums.Sections.Product;

                BussinessManager BussinessManager = new a2mbl.Managers.BussinessManager();

                Business currentBusiness =  BussinessManager.GetBusinessFromMunicipalityNormalizedNameAndBusinessNormalizedNamed(municipality, business);
                if (currentBusiness == null) return View("Error");

                BusinessModel BusinessModel = new BusinessModel();
                BusinessModel.Business = currentBusiness;
                return View(BusinessModel);
            }
            catch (Exception ex)
            {
                a2m.A2MApplication.Log.Error("BusinessController", ex);
                return View("Error");

            }
        }
        public ActionResult Index(string municipality)
        {
            try
            {

                ViewBag.Section = a2m.Common.Enums.Sections.List;

                if (municipality.IsNullOrEmpty()) return View("Error");
                Municipality currentMunicipality = MunicipalityManager.getMunicipalityByNormalizedName(municipality);
                if (currentMunicipality == null) return View("Error");
                MunicipalityModel MunicipalityModel = new MunicipalityModel();
                MunicipalityModel.Municipality = currentMunicipality;
                BussinessManager BussinessManager = new BussinessManager();

                MunicipalityModel.BusinessList = BussinessManager.GetBusinessFromMunicipalityId(currentMunicipality.Pk_Municipality);
                ViewBag.MunicipalityByNormalizedName = municipality;
                return View(MunicipalityModel);
            }
            catch (Exception ex)
            {
                a2m.A2MApplication.Log.Error("MunicipalityController", ex);
                return View("Error");
            }
        }