public JsonResult GetAllSearched(GeoLocalizationDto geoLocalization)
        {
            JsonResult msg = null;

            IList <GeoLocalizationDto> dataSearchedDto = _geoLocalizationService.GetAllGeoLocalization(geoLocalization);

            List <SearchedLocals> dataSearched = new List <SearchedLocals>();

            foreach (GeoLocalizationDto dt in dataSearchedDto)
            {
                dataSearched.Add(
                    new SearchedLocals
                {
                    Id           = dt.GeoLocalizationID,
                    PlaceName    = dt.LocalName,
                    OpeningHours = "9-5, M-F",
                    GeoLong      = dt.Lng,
                    GeoLat       = dt.Lat
                });
            }


            msg = Json(new
            {
                success      = true,
                data         = dataSearched,
                responseText = "<strong>" + "Success reading the data" + "</strong>"
            },
                       JsonRequestBehavior.AllowGet);

            return(msg);
        }
        public JsonResult SaveLocalSearched(GeoLocalizationDto geoLocalization)
        {
            JsonResult msg = null;

            if (!ModelState.IsValid)
            {
                var errorList = ValidationFields.GetModelStateErrors(ModelState);
                msg = Json(
                    new
                {
                    success      = false,
                    errors       = errorList,
                    responseText = "<strong>" + RValidation.RequiredFields + "</strong>"
                },
                    JsonRequestBehavior.AllowGet);
                return(msg);
            }


            try
            {
                var userLogged = SessionHelper.SessioUserLogged;

                //Supervisor Cannot Insert
                if (SessionHelper.IsValidOnlyAdmin(userLogged) ||
                    SessionHelper.IsValidSupportOrCustomerServ(userLogged))
                {
                    geoLocalization.EmployeeID = userLogged.EmployeeID;
                }
                else
                {
                    geoLocalization.EmployeeID = 1; //Suppouse be the Frist "Admin"
                }
                _geoLocalizationService.InsertGeoLocalization(geoLocalization);


                msg = Json(
                    new { success = true, responseText = "<strong>" + RValidation.SuccessRegistration + "</strong>" },
                    JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                logger.Error(string.Format("Error Insert Place:{0} \r\n error: \r\n{1}", geoLocalization.LocalName, ex.Message));

                msg = Json(
                    new
                {
                    success      = false,
                    responseText = "<strong>" + RValidation.UnableToRegister + " " + RHome.LocalName +
                                   "</strong>." + RValidation.TryAgainLater
                }, JsonRequestBehavior.AllowGet);
            }
            finally
            {
                logger.Info(string.Format("Place Searched:{0} from Employee:{1}", geoLocalization.LocalName, geoLocalization.EmployeeID));
            }

            return(msg);
        }
Beispiel #3
0
        public void Test_GeoLocalization_Insert()
        {
            GeoLocalizationDto geoLocal = new GeoLocalizationDto()
            {
                CompanyID = 1, EmployeeID = 1, Lat = "51.522483", Lng = "-0.125034", LocalName = "Russel Square"
            };

            try
            {
                GeoLocalizationService.InsertGeoLocalization(geoLocal);
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"MySql Error: {ex.Message}");
            }
        }
 public string DeleteGeoLocalization(GeoLocalizationDto geoLocalization)
 {
     return(_geoLocalizationRepository.Delete(Mapper.Map <GeoLocalizationDto, GeoLocalizationEntity>(geoLocalization)));
 }
 public void InsertGeoLocalization(GeoLocalizationDto geoLocalization)
 {
     _geoLocalizationRepository.Insert(Mapper.Map <GeoLocalizationDto, GeoLocalizationEntity>(geoLocalization));
 }
        public GeoLocalizationDto FindByID(GeoLocalizationDto geoLocalization)
        {
            var geoLocalizationFirst = _geoLocalizationRepository.FindByID(Mapper.Map <GeoLocalizationDto, GeoLocalizationEntity>(geoLocalization));

            return(Mapper.Map <GeoLocalizationEntity, GeoLocalizationDto>(geoLocalizationFirst));
        }
 public void UpdateGeoLocalization(GeoLocalizationDto geoLocalization)
 {
     _geoLocalizationRepository.Update(Mapper.Map <GeoLocalizationDto, GeoLocalizationEntity>(geoLocalization));
 }
 public IList <GeoLocalizationDto> GetAllGeoLocalization(GeoLocalizationDto geoLocalization)
 {
     return(Mapper.Map <IList <GeoLocalizationEntity>, IList <GeoLocalizationDto> >(_geoLocalizationRepository.GetAllByCompany(Mapper.Map <GeoLocalizationDto, GeoLocalizationEntity>(geoLocalization)).ToList()));
 }