Beispiel #1
0
        public IHttpActionResult PostTerminalGeoLocation(TerminalGeoLocationViewModel geoLocation)
        {
            string serialNo = geoLocation.SerialNo.Trim().ToLower();

            Terminals terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }
            else
            {
                geoLocation.TerminalId = terminal.TerminalId;
                geoLocation.TenantId   = terminal.TenantId;
            }

            int res = TerminalServices.SaveTerminalGeoLocation(geoLocation);

            if (res > 0)
            {
                return(Ok("Success"));
            }
            else
            {
                return(BadRequest("Unable to save records"));
            }
        }
        public int SaveTerminalGeoLocation(TerminalGeoLocationViewModel location)
        {
            var newLocation = new TerminalGeoLocation();

            Mapper.Map(location, newLocation);

            if (newLocation.LoggedInUserId == 0)
            {
                newLocation.LoggedInUserId = null;
            }

            _currentDbContext.TerminalGeoLocation.Add(newLocation);
            int res = _currentDbContext.SaveChanges();

            return(res);
        }