Exemplo n.º 1
0
        public int addLocation(Location location)
        {
            SSGetService    getService    = new SSGetService();
            SSUpdateService updateService = new SSUpdateService();

            Location existingLocation = getService.getLocationByCredentials(location);

            if (existingLocation.name == null)
            {
                using (SqlCommand command = new SqlCommand("INSERT INTO ss_locations(name, type)VALUES(@name,@type)"))
                {
                    command.Parameters.AddWithValue("@name", location.name);
                    command.Parameters.AddWithValue("@type", location.type);
                    int response = service.execute(command);
                    if (response > 0)
                    {
                        this.addLog(new Log()
                        {
                            type        = "Add Location",
                            statement   = command.CommandText,
                            description = "Added new location" + location.name,
                        });
                    }
                    return(response);
                }
            }
            else
            {
                return(-2);
            }
        }